![]() |
|
|
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 |
| How to change field seperator | onthetopo | Shell Programming and Scripting | 2 | 05-11-2007 01:11 PM |
| Using | as a seperator in join | firvin | UNIX for Dummies Questions & Answers | 5 | 03-28-2006 12:23 PM |
| Comma seperator | premar | Shell Programming and Scripting | 6 | 02-17-2006 04:16 AM |
| how i can use a WORD for seperator | qrshat | SUN Solaris | 3 | 02-10-2006 07:08 AM |
| Awk Field Seperator Help | insania | Shell Programming and Scripting | 3 | 11-11-2005 04:29 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
SUBSEP Seperator problem with awk
The following code removes new line with in double quotes I am replacing newline character with in double quotes with 123. Code:
intermediatenewline_remover () {
typeset Infile=$1
nawk -F"," '{ record = record $0
if ( gsub( /"/, "&", record ) % 2 )
{
record = record "123"
next
}
}
{
print record
record = ""
}' Infile
}
Here i am combining 4th and 5th field with "123" as seperator Code:
nawk -F"|" '{print $2,$3,$4"123"$5}' OFS="|" file
Replacing Comma and seperator "123" with space. The problem here is if data has "123" that will also be replaced with space. I want only "123" seperator to be replaced. Code:
nawk -F"|" '{gsub(",", " ",$3);gsub("123", " ",$3);print}' OFS="|" file
I tried using SUBSEP This code instead of using value for SUBSEP "\034" its inserting "SUBSEP" Code:
intermediatenewline_remover () {
typeset Infile=$1
nawk -F"," '{ record = record $0
if ( gsub( /"/, "&", record ) % 2 )
{
record = record "SUBSEP"
next
}
}
{
print record
record = ""
}' Infile
}
and how to handle this change in this code Code:
nawk -F"|" '{print $2,$3,$4"123"$5}' OFS="|" file
nawk -F"|" '{gsub(",", " ",$3);gsub("123", " ",$3);print}' OFS="|" file
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|