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
Is cmd a shell?
What are "c" and "b" permission fields of a file?
State the advantages of shell scripting?
I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?
I want to connect to a remote server and execute some commands, how can I achieve this?
How to check if a directory exists?
What is a shell made of?
How will you find the 99th line of a file using only tail and head command?
Explain about debugging?
What is the command to find out today's date?
How do I stop script errors?
Is shell a part of kernel?
how will you find the total disk space used by a specific user?
Differentiate between ‘ and ” quotes.
What is the equivalent of a file shortcut that we have a window on a linux system?