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


Please Help Members By Posting Answers For Below Questions

Where are cowrie shells found?

574


What is the conditional statement in shell scripting?

657


How can I send a mail with a compressed file as an attachment?

556


What is the best scripting language?

562


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 ?

1714






How to find all the files modified in less than 3 days and save the record in a text file?

610


How can you get the value of pi till a 100 decimal places?

548


Why is shell scripting important?

572


What are the different types of shell scripting?

532


I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?

754


How do I run a shell script in powershell?

554


what is tickets $ what low,medium,high priorite pls define time also

1720


What is the best shell scripting language?

541


What is echo in shell?

638


What is wc in shell script?

557