Jan 14, 2002 #1 Navvy Technical User Apr 12, 2002 64 US Hi... I've been trying to separate fields in AWK using the line: FS = ";" ...where ; is the field separator. However, this doesn't seem to work. Anyone got any ideas/suggestions? Thanks in advance.
Hi... I've been trying to separate fields in AWK using the line: FS = ";" ...where ; is the field separator. However, this doesn't seem to work. Anyone got any ideas/suggestions? Thanks in advance.
Jan 14, 2002 #2 grega Programmer Feb 2, 2000 932 GB Need more info ... If the separator on your input file is a ; then a script like awk '{BEGIN FS=";"} {main awk code here}' should work OK. Greg. Upvote 0 Downvote
Need more info ... If the separator on your input file is a ; then a script like awk '{BEGIN FS=";"} {main awk code here}' should work OK. Greg.
Jan 14, 2002 #3 Krunek Programmer Feb 14, 2001 140 HR Hi Navvy! You can also use command-line argument -Fc to set field separator FS to the charater c; for example: Code: awk -F; '{ # awk code; print }' inputfile Bye! KP. Upvote 0 Downvote
Hi Navvy! You can also use command-line argument -Fc to set field separator FS to the charater c; for example: Code: awk -F; '{ # awk code; print }' inputfile Bye! KP.
Jan 14, 2002 #4 jescat3091 IS-IT--Management Nov 7, 2006 1 US If you are printing to print out multilple values in one line separated by a ";" try this: BEGIN { OFS = ";"; FS = ";" } print $1,$2,$3 Upvote 0 Downvote
If you are printing to print out multilple values in one line separated by a ";" try this: BEGIN { OFS = ";"; FS = ";" } print $1,$2,$3
Jan 15, 2002 Thread starter #5 Navvy Technical User Apr 12, 2002 64 US Hi all... For some reason, none of these suggestions seem to work. The input file looks as follows: ASBA ;USD/HKD ; 7.43423 ;01/09/02 ; 3.4555l; -656565656 Any other suggestions? Upvote 0 Downvote
Hi all... For some reason, none of these suggestions seem to work. The input file looks as follows: ASBA ;USD/HKD ; 7.43423 ;01/09/02 ; 3.4555l; -656565656 Any other suggestions?
Jan 15, 2002 #6 Krunek Programmer Feb 14, 2001 140 HR If I good see, your input file has two lines. Is this correct? Which data you must extract from file? KP. Upvote 0 Downvote
If I good see, your input file has two lines. Is this correct? Which data you must extract from file? KP.
Jan 15, 2002 Thread starter #7 Navvy Technical User Apr 12, 2002 64 US Hey KP... It's all on one line. But there are many records of the same format, all in one input file. I don't know whether the white spaces are a problem? Many thanks in advance for your help. Upvote 0 Downvote
Hey KP... It's all on one line. But there are many records of the same format, all in one input file. I don't know whether the white spaces are a problem? Many thanks in advance for your help.
Jan 15, 2002 #8 vgersh99 Programmer Jul 27, 2000 2,146 US The below seems to work fine printing out the THIRD field from the file "navvy.txt" containig just one line mentioned above. Tell us more HOW you run your script vlad nawk -f navvy.awk navvy.txt ----------------- navvy.awk ---------------------- BEGIN { FS = ";" } { print $3 } ----------------- navvy.awk ---------------------- Upvote 0 Downvote
The below seems to work fine printing out the THIRD field from the file "navvy.txt" containig just one line mentioned above. Tell us more HOW you run your script vlad nawk -f navvy.awk navvy.txt ----------------- navvy.awk ---------------------- BEGIN { FS = ";" } { print $3 } ----------------- navvy.awk ----------------------
Jan 15, 2002 #9 marsd IS-IT--Management Apr 25, 2001 2,218 US With gawk 3.1.0/Linux 2.4.16 awk ' BEGIN { FS = ";" } { for (i=1 ; i < NF ; i++) { print i, $i, NF ,NR, FS } }' file Comes up with all correct info: What do you want the output to look like? Upvote 0 Downvote
With gawk 3.1.0/Linux 2.4.16 awk ' BEGIN { FS = ";" } { for (i=1 ; i < NF ; i++) { print i, $i, NF ,NR, FS } }' file Comes up with all correct info: What do you want the output to look like?
Jan 15, 2002 #10 ganeshmb Programmer Dec 5, 2001 32 US It will be very easy to figure out the problem if you post your script along with the data. Upvote 0 Downvote
Jan 16, 2002 Thread starter #11 Navvy Technical User Apr 12, 2002 64 US Hi all... Firstly, thanks for your efforts! I'm running the script by: cat text.txt | prog.awk >output Upvote 0 Downvote
Hi all... Firstly, thanks for your efforts! I'm running the script by: cat text.txt | prog.awk >output
Jan 16, 2002 #12 vgersh99 Programmer Jul 27, 2000 2,146 US This is amaizing ) Pls post text.txt AND prog.awk I simply hate debuggin' hypotheticals.... vlad Upvote 0 Downvote