I have a command, for example: echo "word1 word2". I want to put a pipe (|) and get "word1" from the command.
echo "word1 word2" | ....
What should I put after the pipe?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
AWK is a good option if you have to deal with trailing whitespace because it’ll take care of it for you:
cut won’t take care of this though:
‘cut’ here prints nothing/whitespace, because the first thing before a space was another space.