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 powershell script?
How to use arguments in a script?
What is computer cli?
What are the different types of shell scripting?
What is a command line shell?
What is the significance of $#?
What is scripting used for?
c program which behaves like a shell(command interpreter). it has its own prompt say "NewShell$".any normal shell command is executed from your shell by starting a child process to execute a system program corrosponding to the command
Is shell scripting difficult?
What is a batch file used for?
What does echo $0 do?
What happens when you type ls?
What is shell and shell script?
How does path variable work?
Explain about debugging?