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
How do I save a powershell script?
Explain about echo command?
What are the different types of shell scripting?
Is shell scripting easy to learn?
How do I run a .sh file?
What is the difference between grep and egrep?
What is bourne shell scripting?
Determine the output of the following command: name=shubham && echo ‘my name is $name’.
What is the syntax of "nested if statement" in shell scripting?
determine the output of the following command: echo ${new:-variable}
What is the use of break command?
What is scripting autism?
What is option in shell script?
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 ?
What is the difference between break and continue commands?