Hi All,
I have a text file which looks like below.
################################################
Name:xxxxxxx
Version:1.0
Class: 2
City : Bangalore
Component Part Action Nb New Part Naming Part Name
12345 default 12345.12345 Bad
23456 default nb 23456.23456 n/a Good
34567 default 34567.34567 Bad
#######################################################################
Now I want to otuput onlt "Component Part" "New Part" "Part Name" columns and the output should look like below Please help me.
Component Part New Part Part Name
12345 12345.12345 Bad
23456 23456.23456 Good
34567 34567.34567 Bad
You can see that first file has a columns arranged randomly and in the output few columns are ignored and rest all must be arranged properly. but here also it looks like random arrangement
cat file | awk '/^[0-9]/' | awk 'BEGIN{print "component Part New Part Part Name"};{n=split($0,tab)}{if(NR==2) {print tab[1],tab[4],$NF} else {print tab[1],tab[3],$NF}}'
Result:
component Part New Part Part Name
12345 12345.12345 Bad
23456 23456.23456 Good
34567 34567.34567 Bad
what home work are you talking about?? I have to submit my script before monday to my team lead.. i'm not a programmer but knows basics thats all...
and even i didnt write any program also...there was a program already with our team but there we need to change few things...like the one above...
please help me
---------- Post updated at 06:03 AM ---------- Previous update was at 05:54 AM ----------
Hi thanks for your reply... checked this and working almost ok but the problem is i should get 12345 exactly under "component part" column n there should be some space between each column.. means columns should be arranged in a proper order,....