can I use awk to extract the first column or any column on a string?
Actually i am using a file and reading it to a variable I want to use AWK on that variable and do my job.
How is it possible? Any suggestions.
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.
Print first column*:
Print second column:
etc.
Where
<some output producing command>is likecat filename.txtorecho $VAR, etc.e.g.
ls -l | awk '{print $9}'extracts the ninth column, which is like an … awkward way ofls -1*Columns are defined by the separating whitespace.
EDIT: If your text is already in a variable, something like:
would work, provided you change 9 to the desired column.