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
c program which behaves like a shell(command interpreter). it has its own prompt say "NewShell$".any normal shell command is executed from your shell by starting a child process to execute a system program corrosponding to the command
What is difference between shell and bash scripting?
What is shell terminal?
What is the crontab?
What makes c shell a more preferable option than the bourne shell?
What does $0 mean in shell script?
Suppose you execute a command using exec, what will be the status of your current process in the shell?
How do you create a shortcut in linux?
What is gui scripting?
What is echo $shell?
What are different types of shell?
What is shell application?
What is eval in shell script?
What will happen to my current process when I execute a command using exec?
How to print all the arguments provided to the script?