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
Where are cowrie shells found?
What is the conditional statement in shell scripting?
How can I send a mail with a compressed file as an attachment?
What is the best scripting language?
Set up a Sev 2 alert when the Primary WA service fails. A windows batch script needs to be created that will monitor the WA service on the Primary and when the service stops/fails a Sev 2 TT is generated for a particular team ?
How to find all the files modified in less than 3 days and save the record in a text file?
How can you get the value of pi till a 100 decimal places?
Why is shell scripting important?
What are the different types of shell scripting?
I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?
How do I run a shell script in powershell?
what is tickets $ what low,medium,high priorite pls define time also
What is the best shell scripting language?
What is echo in shell?
What is wc in shell script?