![]() |
|
|
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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove pipes in file using SED | TL56 | Shell Programming and Scripting | 3 | 10-17-2007 12:03 PM |
| perl help with pipes and file handles (simple issue) | the_learner | Shell Programming and Scripting | 1 | 05-06-2007 06:34 AM |
| doubt about pipes | evergreen_cool | Shell Programming and Scripting | 4 | 09-10-2005 02:05 AM |
| cd using pipes | Sinbad | Shell Programming and Scripting | 2 | 09-09-2004 11:05 AM |
| PIPEs and Named PIPEs (FIFO) Buffer size | Jus | Filesystems, Disks and Memory | 1 | 08-20-2004 11:14 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help with pipes in a file
I have to add pipes for particualr number of records in a file. For eg the file has 10 records and i need to add the "|" for records numbers 7 to 10 at particular positons as shown.
Quote:
Quote:
|
|
||||
|
Thanks Vgresh!!!! Can you help me with this please.
I have to add | at the end of the 8 th field in the below file and that too for all the reocrds in the file Quote:
Quote:
|
|
|||||
|
Quote:
Code:
sed 's/.\{8\}/&|/'
|
|
|||||
|
Quote:
ds.awk: Code:
function setFieldsByWidth( i,n,FWS,start,copyd0)
{
copyd0 = $0
n = split(FIELDWIDTHS,FWS)
if (n == 1) {
print "Warning: FIELDWIDTHS contains only one fie"
print "Attempting to continue." > "/dev/stderr"
}
start = 1
for (i=1; i <= n; i++) {
$i = substr(copyd0,start,FWS[i])
start = start + FWS[i]
}
}
BEGIN {
FIELDWIDTHS="8 9999"
OFS="|"
}
!/^[ ]*$/ {
saveDollarZero = $0 # if you want it later
setFieldsByWidth()
# now we can manipulate $0, NF and $1 .. $NF as we wish
print $0
next
}
1
or Shell_Life's 'sed' |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|