General :: How To Grab Tricky Fields In A String
Mar 28, 2010
I'm writing a script that picks out the time offset in a string, but am trying to figure out a way to print a field based on a match (likely needs to be regex).
Here are some sample fields:
09.900. Either add -12:-1: 0 to existing offset, or restart the slicer with no offset or with offset=00
09.900. Either add -12:-1:30 to existing offset, or restart the slicer with no offset or with offset=00
09.900. Either add -10: 0:-47 to existing offset, or restart the slicer with no offset or with offset=00
What I need would be "-12:-1: 0" from the first line, for example. I was just using "awk '{print $4}'" originally but because of the damn space in the 1st and 3rd lines by the 0, that doesn't work for me. How to grab those fields correctly for all cases?
View 3 Replies
ADVERTISEMENT
Aug 9, 2011
i have a file with a lot of lines in it, and iould like to grab just the line that contains a string i've specified in a variable... Let me know if you want a sample of the file.
View 3 Replies
View Related
May 17, 2010
I'm trying to craft a tricky regex using Sed. I'm trying to clean up some code which has bazillions of lines over 80 characters in length, mainly because of these end-of-line comments. I want to change them to a nicer format. I've put the code on Pastebin because the formatting is better: [URL]. Bear in mind those are tabs, not spaces.
View 1 Replies
View Related
Oct 22, 2010
copy string a to string b and change string b with toupper() and count the chars
View 3 Replies
View Related
Apr 2, 2011
I want to replace a string of directory path in a string to empty:
Code:
But this doesnt seem to give me the desired thing:
Code:
This gives the desired outcome, but its specific, i need a variable in the sed not a string. And if I replace STRING="/mnt/sda1/record/$dd/" then I cant use it for something else, cause its has all the weird backslashes now.
View 3 Replies
View Related
Mar 6, 2011
There is an internet page that displays streaming videos (TV shows) that are not detected by most Windows and Linux downloading software: Orbit, Replay Media Catcher (Windows) or Video Downloader, Downloadhelper, etc in Linux (ubuntu)
In Windows the only program that I managed to do the job with is "Stream Transport", and got .mp4 files that I could watch later.But I don't have windows anymore, it is corrupted. In ubuntu, however, the many firefox add-ons, stand alone programs that I tested, don't see the video file. In the source of the page I don't understand anything, everything is concealed under javascript text... The video is not saved in the firefox cache.
How can I capture it? Does anybody know how to deal with this kind of well-concealed video files?In theory, it should be possible to record everything that comes into the machine, but how?
P.S. By TRICKY I mean something non-standard (not ....., dailymotion, etc).
View 9 Replies
View Related
Jul 12, 2011
I have a file1:
Code:
$ cat PF(1).out
Tmp39 PF10271.3 423 ENSP00000326063 488 1.2e-201 41-478
Tmp39 PF10271.3 423 ENSP00000338165 492 1.9e-200 46-479
[code].....
View 14 Replies
View Related
Nov 4, 2010
i have a file name using the following pattern:
PREFIX: AR
SOURCE: LEGACY
DATETIME: YYYYMMDD_HH24MISS
SUFFIX: .txt
sample filename:AR_LEGACY_20101104_105500.txti want to extract the source which is LEGACY in this case. how do i do this using shell?
View 1 Replies
View Related
Feb 7, 2011
I'm trying to use awk to remove rows that are duplicates based on 3 fields, and I want to keep the on that has the higher value in another field. I'm working in C-Shell. For example the below is greped out of a larger data set to use in here as example:
Input (Field separator is a comma:
Code:
4180,-6999,MA,BARNSTABLE,BOURNE,1,1.7,1700,PM,1/26
4180,-6999,MA,BARNSTABLE,BOURNE,1,3.5,2025,PM,1/26
4180,-6999,MA,BARNSTABLE,BOURNE,1,1.0,1511,PM,1/26
4180,-6999,MA,BARNSTABLE,BOURNE,1,5.7,0540,AM,1/27
[Cpde]....
View 1 Replies
View Related
Feb 22, 2010
I'm looking for a way to dynamically modify a fied in the SQL file.
Example,
INSERT INTO `TABLE` VALUES(1AADFDF,DFF33D,10023,SOMEDATA, SOMEDATA);
INSERT INTO `TABLE` VALUES(1AADFDF,DFF33D,10098,SOMEDATA, SOMEDATA);
[code]....
The third field in this SQL file is what needs to change to n+1
"10023" needs to change to "1"
"10098" needs to change to "2"
"10123" needs to change to "3"
"10983" needs to change to "4"
etc...
I tried with awk and sed, but since both require the usage of ' (single quote), my variable fails to get updated. I know i can use cut and recreate the sql statememnt, but i believe there should be easier way using sed or awk. Would anyone know of any creative way to get this to work in one-liner? This needs to be a part of the script preferable without making call to external file.
View 1 Replies
View Related
Dec 13, 2010
For example: file a:Tom:blackLily:pinkfile b:Tom:bigKate:smallAnd, the result:join -t: a1 a ot:Tom:black:bigLily:pinkBut what I want is:Tom:black:bigLily::pink
View 2 Replies
View Related
Jan 10, 2011
I have a couple of MP3s that have duplicate fields in their ID3 tags. Let me show you what I mean: This is causing problems with some media players. Is there a tool that can automatically fix these MP3s in batch? I'd prefer a free Windows or Linux program. I'm not afraid to work on the command line if necessary.
View 2 Replies
View Related
May 4, 2010
I'd like to take audio track from a video clip in FLV container and save it to something playable by portable music players. Are there any easy to use tools for that? I know how to do that using console tools (mplayer+lame/oggenc), but I'd like to get something clickable, preferably for GNOME.
View 3 Replies
View Related
Jan 13, 2011
I'm trying to get an output of a file in numeric order. Basically I need the starting number and the ending number in sed this into anther file. The test2.lis file I'm just awk'ing for the first row and if its out of order put it in order so I can grab the first and last numbers. I'm sure I can do this all in an array. The first sed command gets rid of blank lines and outputs it to a file. Then I head and tail for the first and last number then I want to sed those numbers into a file that exsist.
[code]...
The error I get is:
sed: -e expression #1, char 24: unterminated `s' command.
View 13 Replies
View Related
Nov 4, 2010
'I am attempting to grab roughly 40 pieces of data that is a combination of 0 and 1 flags from mysql. based off of the 0 or 1... either pictA or pictB will be displayed. How to evaluate my code? I believe the logic is incorrect.
PHP Code:
$status = 'mysql -u username -ppassword -h x.x.x.x -e 'SELECT help FROM table' database';
declare -A ARRAY
for ((i=1; i=$status; i++));
do
echo ${ARRAY[$(i)]}
done
if [${ARRAY[]} = 1];
then echo "<img src='pictA.gif'>";
else [${ARRAY[]} = 0];
echo "<img src='pictB.gif'>";
fi
View 4 Replies
View Related
Dec 2, 2010
I am trying to remove the space between the 2nd and 3rd fields but just cannot work out how to do it. I've considered sed, cut, awk...I know with sed you can replace all instances within a file but can you also specify to remove, say, the 2nd instance of a space in each line (this would be perfect for me)?
DAAE 60 402 Bejaia Algeria 1 36-43N 005-04E 36-43N 005-04E 2 2 P
DAAG 60 390 Dar-El-Beida Algeria 1 36-43N 003-15E 36-43N 003-15E 25 25 P
DAAJ 60 670 Djanet Algeria 1 24-33N 009-28E 24-33N 009-28E 1054 1054 P
[code]...
View 3 Replies
View Related
Feb 26, 2011
I have following in cpuinfo:
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
[code]....
View 2 Replies
View Related
Mar 7, 2010
i use this script to get the time and date of back and fourth transactions for a particular execution id. I use a substr command on the 5th column to to cut the milli seconds off the time value. - otherwise the times would look like 08:30:04.235
grep <executionID> <auditfile> | awk '{ print $1, $2, $3, $4, substr($5,1,8}
FIX -> Mon 3/1/2010 08:30:04
FIX <- Mon 3/1/2010 08:32:36
FIX <- Mon 3/1/2010 08:35:08
[code].....
anyhow - i append two sed commands to further clarify the direction of the message.
awk '{ print $1, $2, $3, $4, substr($5,1,8} | sed -e 's/->/ ->IN/g' | sed -e 's/<-/<-OUT/g'
FIX -> IN Mon 3/1/2010 08:30:04
FIX <- OUT Mon 3/1/2010 08:32:36
[code]....
I tried using an awk gsub () command within the string instead of the two seds, but it did not work:
awk '{ print gsub(/<regex>/, <replace with>,$1), $2, $3, $4, substr($5,1,8}
the sed works ok, but it would be cooler to make the replacement within the awk command:
gsub(/->/,-> IN, $1)
Is there a way where i could replace the value of the $1 column in the awk print string?
View 1 Replies
View Related
Apr 23, 2011
I have a huge log file of around 3.5 GB and would like to sample random sections in the middle of say 10 MB for the purpose of debugging what my application is doing.
I could use head or tail commands to get the beginning or end of the file, how can I grab an arbitrary portion from the middle of the file? I guess I could do something like head -n 1.75GB | tail -n 10MB but that seems clumsy and I'd need to determine line numbers for the midpoint of the file to get 1.75GB and 10MB line counts.
View 2 Replies
View Related
Jan 18, 2010
I have found many information about how to delete/grab a line in a text file including delete line with match a pattern but I did not find info about how to delete a line which match a pattern of a particular column only.
for example mydata.txt:
id type x y z
1 6 0.474611 0.227223 0.583947
[code]....
View 6 Replies
View Related
Jun 11, 2011
Moving right along, I have a folder of MP3 files containing various Movie sound tracks and scores. I'm using Audio Tag Tool to tag all the files at once with an "Artist" of "Soundtrack", and to inherit the "Title" tag from the file name. After that, I will rename all the files (Using Audio Tag Tool -- awesome program, btw) with the format "<Artist> - <Title>.mp3"
The problem, is many of my files already contain the string "Soundtrack", which would be redundant. I happen to be a perfectionist, so I'm unable to ignore it and move on. Hence my question to you fine folk: I want to delete all instances of "soundtrack" (-i case irrelevant) in the filenames before I go through the above steps. But, its not quite that simple. This is a sample of some of the file names:
[Code]....
View 3 Replies
View Related
May 26, 2011
I recently installed ubuntu 10.10 replacing fedora 10. installation was successful but when I start Ubuntu, computer halts showing two line error [18.929065]mpu401_uart:unable to grab port 0x330 size 2 [18.929125]cmipci: no UART401 device at 0x330 Even reinstalling could not solve problem If this is related to audio then in Fedora 10 everything was working fine. But I could start Ubuntu selecting recovery mode with option 'single' then from recovery menu 'boot as normal', providing username and password and typing 'startx'. How can fix this error?
View 2 Replies
View Related
May 3, 2011
I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.
[Code]....
One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?
Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.
View 6 Replies
View Related
Mar 17, 2011
I have a tab delimited file with 2 columns.
2224 23943843
5494 39843843
8372 48938384
I have to loop through this file and copy the files with the first field to a new name that contains both the first and second field. To be more specific, file quote2224.pdf has to be copied to 23943843_quote2224.pdf file quote5494.pdf has to be copied to 39843843_quote5494.pdf I don't know how or if it's even possible to use a for loop and access both fields. I don't know how to copy files in awk.
View 1 Replies
View Related
Sep 1, 2010
I have a mytext file with month and year as two separate fields. likemytext fil
08 2010
09 2010
10 2010
........
........
........
I want to read the values of each field i.e., month and year into an awk script.
View 10 Replies
View Related
Sep 2, 2010
I have a line in a text file that has 40 random characters within a tag and i want to change the characters to a new set of 40 random characters (alphanumeric a-z 0-9 etc)
The line in the text file looks like this:
Quote:
How would i go about doing that?
Also second question same as the above but how would i remove them instead of replacing them?
View 14 Replies
View Related
Apr 26, 2011
If I have a word in a text file and I need to replace it by another word (for example, i need to replace abc by fff) so what is the command I can type it?
I am using vi editor.
View 3 Replies
View Related
Mar 7, 2011
I have a String that I would like to sign using a given RSA Private key. I thought this would be relatively easy but I have not been able to find out how to do it, unless I'm looking to far into a simple problem. Do i have to put the string into a file, and sign the file, or can i just sign the string/message?
View 7 Replies
View Related
Oct 16, 2010
I have a set of lines as ahown below:
Leon went to school
Leon came back from school..
Leon had dinner...
I have to replace the line containing "dinner" by a single string LUNCH...
View 2 Replies
View Related
Feb 25, 2011
I need to creates string suffixes out of a Reference string. for eg. suffixes of abcdefg will be
1)bcdefg
2)cdefg
3)defg
and so on...
create an array of pointers to point to the first few characters and then use that pointer to print the rest of the string.But when i print using the pointer i get GARBAGE values! shudn't std::cout<<ptr[w] print the string following the char it is pointing to? why do i get garbage values?
View 9 Replies
View Related