If you continue to refuse to use CODE tags as required by forum rules, you may be banned from this site! Please use CODE tags and stop depending on forum moderators to edit your posts for you.
Quote:
There are multiple files or 1 file of text file that contains different entries for each line that I will expect to grab the string/field for each line.
There is never any need to use cat to feed input into sed, cut, or awk. All of those utilities are perfectly capable of reading files directly without using cat to unnecessarily read and write the contents of the files an extra time.
Please explain how you identify the string field in each of these lines. Sometimes it contains a period; usually it does not. Sometimes it contains part of the last pathname component of a pathname; sometimes it contains part of a directory name in that pathname as well; sometimes it doesn't. Sometimes your data starts with a pathname; sometimes it doesn't.
I'm very glad that Aia's suggestion is working for you. With the input you have provided in posts #1 and #7 (with the input from post #7 including the line number and with it not including the line numbers, since you didn't use CODE tags in your post and I couldn't tell whether or not that text was intended to be in the file):
I get the output:
which does not match what you said you wanted as output from any of those lines:
Where the text shown in red does not match what was requested and in some cases additional output was provided that you didn't says was what you wanted.
Showing us more seemingly random input and output without specifying what rules govern how the string field to be printed is determined is a waste of our time.
Ok, I'm stumped and can't seem to find relevant info.
(I'm not even sure, I might have asked something similar before.):
I'm trying to use shell scripting/UNIX commands to extract URLs from a fairly large web page, with a view to ultimately wrapping this in PHP with exec() and including the... (2 Replies)
Hi,
Need to extract a string from one file and search the same in other files.
Ex:
I have file1 of hundred lines with no delimiters not even space.
I have 3 more files.
I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
so i have hundreds of files named history.20071112.tar
(history.YYYYMMDD.tar)
and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis
here is what i have so far:
for FILE in `cat dirlist`
do
tar xvf $FILE ./status_*
done
dirlist is a text... (4 Replies)
Input file is on Linux box and the input file has data in just one line with 1699741696 characters.
Sample Input:
<xxx><document coll="uspatfull" version="0"><CMSdoc>xxxantivirus</CMSdoc><tag1>1</tag1></document><document coll="uspatfull"... (5 Replies)
Hi ,
I have input file and i want to extract below strings
<msisdn xmlns="">0492001956</ msisdn> => numaber inside brackets
<resCode>3000</resCode> => 3000 needs to be extracted
<resMessage>Request time
getBalances_PSM.c(37): d out</resMessage></ns2:getBalancesResponse> => the word... (14 Replies)
Can someone tell me how I can do this?
e.g:
Say file1.txt contains:
today is monday
the 22 of
NOVEMBER
2010
and file2.txt contains:
the
11th
month
of
How do i replace the word NOVEMBER with (5 Replies)
Hi all,
Given a file name such as
EXAMPLE=lastname-02.30.71-firstname-town-other.tar.gz
How do I print everything before the first dash (i.e. lastname)
Note: I do not know exactly how many dashes or what information there will be in each file name so it is important that the code... (2 Replies)
Can someone tell me how I can do this?
e.g:
a=$(echo -e wert trewt ertert ertert ertert erttert
erterte
rterter
tertertert
ert)
How do i replace the STRING with $a?
I try this:
sed -i 's/STRING/'"$a"'/g' filename.ext
but this don' t work (2 Replies)
Hello. I am sorry if this is a common question but through all my searching, I haven't found an answer which matches what I want to do.
I am looking for a sed command that will parse through a large text file and extract lines that start with specific words (which are repeated throughout the... (4 Replies)