Hi All,
I am trying to read first column of my file using command
cat temp2_sample.cir|cut -d' ' -f1
The content of my file is as follow
R1 pin23I pin27I
R2 pin23G pin27G
R3 pin27F pin27D
RWire10 pin15Y pin23J
VCC1 pin27W pin13Y
RWire21 pin28W pin27B
Here I am getting output as
R1
R2
R3
RWire10
VCC1
I am not getting RWire21 in my output. Initially I thought it could be due to more space but if that is the case then R1 and RWire10 should also be not printed.
Please advise me where I can do changes in my command.
Thanks and Regards
---------- Post updated at 03:46 AM ---------- Previous update was at 03:44 AM ----------
Please consider space before R1 and both RWire. It is not showing in forum.
pamu
July 29, 2013, 4:55am
2
diehard:
Hi All,
I am trying to read first column of my file using command
cat temp2_sample.cir|cut -d' ' -f1
The content of my file is as follow
R1 pin23I pin27I
R2 pin23G pin27G
R3 pin27F pin27D
RWire10 pin15Y pin23J
VCC1 pin27W pin13Y
RWire21 pin28W pin27B
Here I am getting output as
R1
R2
R3
RWire10
VCC1
I am not getting RWire21 in my output. Initially I thought it could be due to more space but if that is the case then R1 and RWire10 should also be not printed.
Please advise me where I can do changes in my command.
Thanks and Regards
---------- Post updated at 03:46 AM ---------- Previous update was at 03:44 AM ----------
Please consider space before R1 and both RWire. It is not showing in forum.
Please use code tags for code and data sample.
try
awk '{ print $1}' file
1 Like
millan
July 29, 2013, 5:03am
3
sed 's/^ //g' temp2_sample.cir | awk -F" " '{print $1}'
No change I am getting same result.
Here is my file
R1 pin23I pin27I
R2 pin23G pin27G
R3 pin27F pin27D
RWire10 pin15Y pin23J
VCC1 pin27W pin13Y
RWire21 pin28W pin27B
zaxxon
July 29, 2013, 5:08am
5
Getting same result using which code?
If you use Pamu's code you should get something like:
$ cat infile
R1 pin23I pin27I
R2 pin23G pin27G
R3 pin27F pin27D
RWire10 pin15Y pin23J
VCC1 pin27W pin13Y
RWire21 pin28W pin27B
$ awk '{print $1}' infile
R1
R2
R3
RWire10
VCC1
RWire21
1 Like
Thanks All for your reply.
I am getting result with pamu's code.
But I still dont understand why there is issue with cat and cut command.
cut will treat every space delimiter as separate column. so eliminating the spaces and aligning the output will be good with cut. awk will be able to handle task like this easily.
1 Like