10-09-2007
awk 2 delimiter nested Problem
Hello All, This work could be very easy for you guys. I would really appreciate help.
input file:
Quote:
aa|bb|cc|dd,ee ff,xx|gg,zz|hh,bv
ii|jj|kk|ll,mm|nn,as|oo,lk
pp|qq|rr|ss,tt uu,yy|vv,xc|ww,mn
output file: (Desired)
Quote:
num=aa value=bb digits=cc name1=dd:link1=ee name2:ff:link2=xx file=gg:link=zz code=hh:link=bv
num=ii value=jj digits=kk name1=ll:link1=mm file=nn:link=as code=oo:link=lk
num=pp value=qq digits=rr name1=ss:link1=tt name2=uu:link2=yy file=vv:link=xc code=ww:link=mn
What I am capable of doing:
Command: cat inputfile | awk -F\| '{print "num="$1" value="$2" digits="$3" name1="$4" file="$5" code="$6}' > outputfile
Result what I am capable of getting:
Quote:
num=aa value=bb digits=cc name1=dd,ee ff,xx file=gg,zz code=hh,bv
num=ii value=jj digits=kk name1=ll,mm file=nn,as code=oo,lk
num=pp value=qq digits=rr name1=ss,tt uu,yy file=vv,xc code=ww,mn
As per my understanding some tricks to that command is needed to involve nested 2 delimiters (i.e. "|" & "," & " "(space) chracter). I dont have any idea how to go about it. Could anyone solve this thing for me or give me some diff logic to acheive this desired output file.
I would really appreciate if some one helps as soon as poss. Thanks a lot people.
Last edited by onlyroshni; 10-09-2007 at 07:54 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hey all,
Can I put sed command inside the awk action ?? If not then can i do grep in the awk action ??
For ex:
awk '$1=="174" { ppid=($2) ; sed -n '/$ppid/p' tempfind.txt ; }' tempfind.txt
Assume: 174 is string.
Assume: tempfind.txt is used for awk and sed both.
tempfind.txt... (11 Replies)
Discussion started by: varungupta
11 Replies
2. Shell Programming and Scripting
Hello - is there any way in awk I can do...
4861 x(1) y(1) z(1)
4959 x(1) y(1) z(1)
5007 x(1) y(1) z(1)
4861 x(2) y(2) z(2)
4959 x(2) y(2) z(2)
5007 x(2) y(2) z(2)
4861 x(3) y(3) z(3)
4959 x(3) y(3) z(3)
5007 x(3) y(3) z(3)
to become...
4861 x(1) y(1) z(1) 4861 x(2) y(2) z(2)... (3 Replies)
Discussion started by: catwoman
3 Replies
3. Shell Programming and Scripting
Hi Friends.
Please have a look at dummy file. I need to extract from this file:
1. Counts of event=
2. the 2nd coulmn is unique call id of this transaction. Based on that, i have to search for txstatus= .
Note: Values of event, calltype and txstatus can be anything.
I want to print... (1 Reply)
Discussion started by: itsmesanju
1 Replies
4. Shell Programming and Scripting
Hello all,
I am writing up an input file and I was hoping I could get some guidance as to how to best consolidate these 2 awk statements for 1 while loop.
Here's my input file
# cat databases.lst
#NOTE: These entries are delimited by tabs "\t"
#oracleSID name/pass
#
db11 ... (2 Replies)
Discussion started by: Keepcase
2 Replies
5. Shell Programming and Scripting
please let me know if the below code could be written efficiently inside single awk
case "$INP" in
ksh)
cat catalog | awk 'BEGIN {FS=",";} { print $2 } END {}'
;;
pset)
cat catalog | awk 'BEGIN {FS=",";} { print $3 } END {}'
;;
dml)
cat catalog | awk 'BEGIN {FS=",";} {... (2 Replies)
Discussion started by: cvsanthosh
2 Replies
6. Shell Programming and Scripting
Folks - newbie bash coder here and I'd like to get your help to make the code below work. As you can see, I was trying to count the total number of lines with the 3rd value >= 15 in a file and wanted to make the threshold "15" configurable, but apparently the $THRESHOLD value was not populated... (3 Replies)
Discussion started by: bashzipper
3 Replies
7. Shell Programming and Scripting
Hello again everyone,
yes, I'm back again for more help! So I'm attempting to read two separate files and generate some XML code from that. My current code is:
BEGIN {
print "<?xml version=\"1.0\" encoding=\"utf-8\">"
print "<Export>"
}
{
x=1;
print "<section name=\"Query" NR "\">"... (5 Replies)
Discussion started by: Parrakarry
5 Replies
8. Shell Programming and Scripting
Hi Gurus,
I have a command to assign value based on input value.
current condition is "if pattern matches "case", then assign "HOLD" else "SUCC"right now, I need to add one more condition (variable name is VAR).
the condition is "if pattern1 matches "case", then assign "HOLD" else if... (2 Replies)
Discussion started by: ken6503
2 Replies
9. Shell Programming and Scripting
I am trying to parse a text file and send its output to another file but I am having trouble conceptualizing how I am supposed to do this in awk.
The text file has a organization like so:
Name
Date
Status
Location (city, state, zip fields)
Where each of these is on a separate line in... (1 Reply)
Discussion started by: kellyanneghj
1 Replies
10. Shell Programming and Scripting
Hello.
I would like to convert the following piece of code from bash to awk.
Here are bash variables in a bash script.
CUR_ROW_ID and ROW_ID_TO_SEARCH contains a string which represent a row id.
The string contain a valid row id.
CUR_ROW_ID sometimes may be null.
CUR_VALUE... (3 Replies)
Discussion started by: jcdole
3 Replies
ED2K(1) aMule utilities ED2K(1)
NAME
ed2k - aMule eD2k link parser
SYNOPSIS
ed2k [-c <path>] [-t <num>] [-e] [-l] <eD2k-link>
ed2k [-h]
ed2k [-v]
DESCRIPTION
Sends the given <eD2k-link> to aMule, i.e. writes it to the file ~/.aMule/ED2KLinks, which will be checked by aMule every second for links.
[ -c <path>, --config-dir=<path> ]
Read config from <path> instead of home
[ -t, --category=<num> ]
Set category for passed eD2k links to <num>
[ -e, --emulecollection ]
Loads all link found in the emulecollection given as <ed2k-link>
[ -l, --list ]
Lists all link found in the emulecollection given as <ed2k-link>
[ -h, --help ]
Prints a short usage description.
[ -v, --version ]
Displays the current version number.
[ eD2k-link ]
Adds an eD2k-link to the core.
The eD2k link to be added can be:
o a file link (ed2k://|file|...), it will be added to the download queue;
o a server link (ed2k://|server|...), it will be added to the server list;
o a serverlist link, in which case all servers in the list will be added to the server list;
o a magnet link;
o an emulecollection file.
The order in which you give the parameters is important. You can give more than one link, and every link can have it's own params. For
example ed2k <link1> -t2 <link2> will download <link1> in standard category and <link2> in category 2.
FILES
~/.aMule/ED2KLinks
REPORTING BUGS
Please report bugs either on our forum (http://forum.amule.org/), or in our bugtracker (http://bugs.amule.org/). Please do not report bugs
in e-mail, neither to our mailing list nor directly to any team member.
COPYRIGHT
aMule and all of its related utilities are distributed under the GNU General Public License.
SEE ALSO
amule(1)
AUTHOR
This manpage was written by Vollstrecker <amule@vollstreckernet.de>
aMule eD2k link parser v1.5.1 November 2011 ED2K(1)