If you have a string "one two three", which shell command
would you use to extract the strings?
Answer Posted / swaroopa
Below methods will work. You could use either cut or awk
echo "read data"
read data
echo $data | cut -f1 -d" "
echo $data | cut -f2 -d" "
echo $data | cut -f3 -d" "
echo $data |awk -F" " '{print $1}'
echo $data |awk -F" " '{print $2}'
echo $data |awk -F" " '{print $3}'
Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
How do I run a shell script in powershell?
Please give me example of " at command , contrab command " how to use
How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?
How to check if the previous command was run successfully?
What makes c shell a more preferable option than the bourne shell?
How to find all the files modified in less than 3 days and save the record in a text file?
What is the significance of $#?
What is a beat in a script?
How to write a function?
how will you find the total disk space used by a specific user?
what is tickets $ what low,medium,high priorite pls define time also
What does echo $0 do?
What is awk in shell scripting?
How to open a read-only file in the shell?
What is the conditional statement in shell scripting?