I need to split the fields in some text strings into separate variables.
The fields are separated by pipes.
The strings look roughly like this:
Currently I can do it using something like cut -d"|" -f1, but when I put that into a while loop (need to go through the text file line by line), it stops working.
Here is the code I have now:
I'm wondering if it is the presence of the pipe character which is confusing the shell.
I'm willing to try any alternative approach people can suggest. I know this should be simple, but I just can't get it to work.
Any help VERY much appreciated.
TIA, Alan.
Last edited by Franklin52; 06-03-2010 at 03:07 AM..
Reason: Please use code tags!
Dear Ladies & Gents,
I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out:
for filename in $(find /var/log/test... (2 Replies)
Hello.
Following recommendations for one of my threads, this is working perfectly :
#!/bin/bash
CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" )
Now I need a grep success for some thing like :
#!/bin/bash
CNT=$( grep -c -e "some text_1... (4 Replies)
Hi Experts.
I'm stuck with the below AWK code where i'm trying to move the records containing any special characters in the last field to a bad file.
awk -F, '{if ($NF ~ /^|^/) print >"goodfile";else print >"badfile"}' filename
sample data
1,abc,def,1234,A *
2,bed,dec,342,* A ... (6 Replies)
I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here.
I have following script (called out_to_streams.csh):
#!/bin/tcsh -f
echo Redirected to STDOUT > /dev/stdout
echo Redirected to... (2 Replies)
logs:
"/home/abc/public_html/index.php"
"/home/abc/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
how to use "cut" or "awk" or "sed" to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
Hello everyone
Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried
sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
i am having text file below
NARGU S S 12358 SALES REP |22| Acccount/s
RAJU R B 64253 SALES REP |12| Acccount/s
RUKMAN S 32588 SALES REP |10| Acccount/s
NARGUND S S 12356... (3 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
I have a text file like:
The name of the project = "Symbion centrifuge"
The name of the subsytem = "motor demon"
now i would like to read the string after the = into a variable to write it to another file.
later use like:
sed s/'PROJECTNAME'/"$projectname"/ <header.tex >temp
... (9 Replies)