Not sure what is the command that i can use to extract and display the data only on column 3(eg, aaa,bbb,ccc) then elimanate the line that without aaa,bbb,ccc and any others unmatched attributes(eg eng,ggg,ddd...)
Sanjay's code works on the input posted - which seems to differ from the input you're actually using: there's no line '612 ... fff ...' in the data given to us, and to my knowledge, grep is not that creative
I'm sorry , acutally i didn't gave the full set of data from my file(i just copy a part from my file) and that's why you guys did not see the line with "612 023/w03 fff bbb ccc"....
my 1st question, for the column with bold:
what is the suitable command(other than grep) use to extract and eliminate all unwanted alphabet/symbol/number and display exactly "aaa","bbb" and "ccc"...
my 2nd question, for the column 2 with "/":
What is the most appropriate/eazy command to help me remove 1st and 2nd "/" and then replace the 3rd "/" with "."
Thank you very much...
To have a better understand, could you please help to give a simple brief on every switchs that you have applied on awk command?
at the very begining $1(field 1) then space and $2(field 2 ) are getting stored in variable x.
then the "for loop" concept is here started from the third field unwards and should be compared for the "if condition"if ($i~"^aaa"||$i~"^bbb"||$i~"^ccc"){$i=substr($i,1,3);x=x" "$i} (which is if the particular field will be starting by "aaa" or "bbb" or "ccc") then make the $i which is the corrent field to it first 3 character(suppose a field is aaa#6 then the first 3 character which is "aaa" will be stored in$i) and the x is again modified to x" "$i(which is nothig but its content with a space and the current field ) and finally print x does the printing of the content of x which is nothing but the first two field of the lines and all the matches of aaa bbb ccc.
you can remove the red code which also give the same output
awk '{x=$1" "$2; for (i=3;i<=NF;i++){ if ($i~"^aaa"||$i~"^bbb"||$i~"^ccc"){$i=substr($i,1,3);x=x" "$i}}; print x;x="" }' infile |awk 'NF>2 {print $0}'|sed 's/\//./3g
s/\///g'