Search Results

Search: Posts Made By: prohank
1,710
Posted By RudiC
It doesn't consider <TAB> chars as those were not...
It doesn't consider <TAB> chars as those were not mentioned in post#1 nor in the examples. Try [[:space:]]* in lieu of the two * in my proposal.
1,710
Posted By Don Cragun
It's not nice to change your problem statement...
It's not nice to change your problem statement after someone has posted code that attempts to solve your original problem. Readers now can only guess at the problem that Ravinder was trying to help...
4,292
Posted By RudiC
Try awk ' NR == 1 {KN = split (KEYCOL,...
Try awk '
NR == 1 {KN = split (KEYCOL, KC, ",")
AN = split (AGGCOL, AC, ",")
}
{KEY = DX = ""
for (i=1; i<=KN; i++) ...
4,292
Posted By RudiC
Next version: duplicate field contents removed;...
Next version: duplicate field contents removed; multiple OFS reduced to single:
awk '
NR == 1 {KN = split (KEYCOL, KC, ",")
AN = split (AGGCOL, AC, ",")
}...
4,292
Posted By RudiC
This is how far I can get right now: awk ' ...
This is how far I can get right now:

awk '
NR == 1 {KN = split (KEYCOL, KC, ",")
AN = split (AGGCOL, AC, ",")
}
{KEY = ""
...
4,292
Posted By RudiC
No surprise it doesn't work for you, as it by no...
No surprise it doesn't work for you, as it by no means fits the problem. Try

awk '{F[$1] = F[$1] DL[$1] $2; DL[$1] = ","} END {for (f in F) print f, F[f]}' file
B00000 abc
B00001...
3,860
Posted By MadeInGermany
The awk solution also takes care of the first and...
The awk solution also takes care of the first and last fields.
The sed and perl solutions need an extra implementation for it.
sed multi-line:
sed '
:L
s/||/|-|/g
tL
s/^|/-|/
s/|$/|-/
' file
3,860
Posted By MadeInGermany
Many Unix sed have parser bugs with semicolon. ...
Many Unix sed have parser bugs with semicolon.
I recommend multi-line
sed '
:L
s/||/|-|/g
tL
' file
Or at least multi -e (less readable, but a must with t/csh that is not multi-line capable)...
3,860
Posted By Don Cragun
This should work: awk...
This should work:
awk 'BEGIN{FS=OFS="|"}{for(i=1;i<=NF;i++)if($i=="")$i="-"}1' /tmp/opt.del > /tmp/opt2.del
If you are trying this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
3,860
Posted By Aia
Please, try: perl -pe 's/\|(?=\|)/\|-/g' file
Please, try:
perl -pe 's/\|(?=\|)/\|-/g' file
Showing results 1 to 10 of 10

 
All times are GMT -4. The time now is 06:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy