1
 row1    row2         row3
Hello,   World,    Hello World
World,   Hello,    World Hello

How do you grab the entire 2 words in bash? I have tried and all I could do is using echo $a tr -s ' ' | cut -d , -f 3 to get both words but each word will be put on its own line like:-

Hello
World
World
Hello
1
  • 1
    Is this is a .csv file, why are you using echo $a? Provide a clear verifiable input and an expected output Commented Sep 8, 2017 at 7:20

1 Answer 1

1

Using awk with custom field separator as space or comma:

awk -F '[ ,]+' 'NR>1{print $1, $2}' file

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.