1833958 Members
2039 Online
110063 Solutions
New Discussion

The cut command

 
SOLVED
Go to solution
Shane Russell
Regular Advisor

The cut command

Hi,

Please have a look at this output:

root@locutus:/failover/bin # grep 079B /var/tmp/symmir_CRMT8.out
0 CRMT8_001 079B * 0 Split

I want to cut CRMT8 out of that line …

root@locutus:/failover/bin # grep 079B /var/tmp/symmir_CRMT8.out | cut -c 28-32
CRMT8

… will do it but that restricts me to positions 28-32.

How can I cut from position 28 to the "_"?

Can anyone shine a light on this for me

regards,
Shane
2 REPLIES 2
Ninad_1
Honored Contributor
Solution

Re: The cut command

If the pattern you have mentioned is fixed then you can try this

grep 079B /var/tmp/symmir_CRMT8.out | awk '{print $2}' | cut -f 1 -d "_"

Regards,
Ninad
Shane Russell
Regular Advisor

Re: The cut command

Thanks Ninad,

That worked perfectly - 10 points

regards,
Shane