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 are the different communication commands available in the shell?
What is console line?
What is $1 in shell scripting?
Is powershell a language?
What is the first line of a shell script called?
What language is shell scripting?
What makes c shell a more preferable option than the bourne shell?
What is shell terminal?
Tell something about the super block in shell scripting?
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 a beat in a script?
What is bash used for?
What is the use of .sh file?
What is a shell environment?
What is the default shell of solaris?