![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
OFS is inbuild command in awk.
I have a file file.txt abc : def : ghi jkl : mno: pqr stu : vwx :yzz code i used: awk -F ":" 'BEGIN {OFS="|"} {print $1,$2}' file.txt output: abc def jkl mno stu vwx but as i have used OFS="|" and i am expecting output as: abc | def jkl | mno stu | vwx I am on the rite track? plz ne 1 help me... |
|
||||
|
OFS is inbuild command in awk.
I have a file file.txt abc : def : ghi jkl : mno: pqr stu : vwx :yzz code i used: awk -F ":" 'BEGIN {OFS="|"} {print $1,$2}' file.txt output: abc def jkl mno stu vwx but as i have used OFS="|" and i am expecting output as: abc | def jkl | mno stu | vwx I am on the rite track? plz ne 1 help me... |
|
|||||
|
works for me: Code:
$ cat newfile.txt
abc : def : ghi
jkl : mno: pqr
stu : vwx :yzz
$ awk -F ":" 'BEGIN {OFS="|"} {print $1,$2}' newfile.txt
abc | def
jkl | mno
stu | vwx
$
this is the same question you asked here |
![]() |
| Bookmarks |
| Tags |
| awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|