You could create two awk scripts - the first gets just the first fields and the second gets from field 2 to the end of the line. I chose to create one awk script that places a pipe symbol between the first and second fields. Then I use a while loop to do the parsing. I export the variables if I want to use them outside of the inner while loop:
as you said- So I want to print something like $1, $2* (the star being to the end of the line)
End of the line.. You can try this although it is the same as printing the whole line....if you cud give me the sample input with different variations and what exactly you are trying to do..it will be easier...
awk '{ first=$1; min=index($0," ")-index($2,"/")+1;max=length($0);print "first one is", first,"second one is ",substr($0,min,max)}' infile
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE