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 does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?
What are the zombie processes?
How do I read a .sh file?
What is the syntax of while loop in shell scripting?
What is computer cli?
What are the default permissions of a file when it is created?
Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.
I want to connect to a remote server and execute some commands, how can I achieve this?
What does it mean to debug a script?
What is the command to find out users on the system?
Is shell scripting useful?
How does path variable work?
What is the use of "$#" in shell scripting?
How do you know which shell I am using?
What is the fastest scripting language?