Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace tab with ¦ 1

Status
Not open for further replies.

7280

MIS
Apr 29, 2003
331
IT
Hi,
i need to replace in a file the tab with |
I did
cat filename | awk -f '{FS=TAB,OFS="|" print $0}'
it's wrong of course.
I checked the man but's confusing.
Is there a good reference guide on the net of awk with examples and simple to understand?
thanks
Tarek
 
Ok... i modified it but it's not working
i created an awk program file, script.awk:
BEGIN { FS=" " ; OFS"|" }
{ print $0 }

then i run:
cat filename | awk -f script.awk | more
but it isn't replacing the tab.

I tried for FS also TAB and "TAB" but not working
 
sed "s/`echo '\t'`/\|/g" file

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
sed achieved what i want, but i'd like to know also how to do it with awk
how can i specify tab?
thanks
 
BEGIN {
FS=&quot;[\t]&quot;
OFS=&quot;|&quot;
}

{
$1=$1
print
}


vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
or better yet:

BEGIN {
FS=&quot;[\t]&quot;
OFS=&quot;|&quot;
}

$1=$1

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top