If you have a string "one two three", which shell command
would you use to extract the strings?
Answer Posted / narendrasairam
Though cut command works, if the string is too long you cant
expect redundancy in the code. So, better to translate the
spaces first and then reading the lines.
echo "enter the string :"
read string
echo $string | tr " " "\n" | sed '/^$/d' > lines.out
while read line
do
echo $line
done < lines.out
Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
What is eval in shell script?
Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.
What is an sh file?
How can you get the value of pi till a 100 decimal places?
Differentiate between ‘ and ” quotes.
What is $1 in shell scripting?
What are the 3 standard streams in linux?
What does egrep mean?
How will you print the login names of all users on a system?
What can you do with powershell?
What are the different types of variables used in shell script?
How will you pass and access arguments to a script in linux?
c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and exit on pressing Ctrl-C again
What are the different variables present in linux shell?
How to print the first array element?