0

I'm trying to extract the two last column of a fixed width file.

Example :

 1 Thu Aug 19 21:54:38 2021 125094     4856 PC7C042B7 PTE VC965
 2 Sat Jul 31 04:09:44 2021 174434     4154 PC2C2EF9E PTP VC965
 3 Sat Aug 14 17:19:04 2021 8538286    4070 PCEECA8B2 PTE VC965

I want to retrieve two last columns :

PTE VC965 PTP VC965 PTE VC965

i tried this but getting another result :

cut -d" " -f10,11 < infile

Thanks for your help

1 Answer 1

2

Try with

cat test.txt | tr -s '[:space:]' | cut -d " " -f 10-11

The tr command will reduce several whitespace into a single whitespace. Then the cut command knows how to get the last two fields.

Found the tr command at https://stackoverflow.com/a/22940570/319826

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.