Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

If you have a string "one two three", which shell command
would you use to extract the strings?

Answer Posted / swaroopa

Below methods will work. You could use either cut or awk

echo "read data"
read data

echo $data | cut -f1 -d" "
echo $data | cut -f2 -d" "
echo $data | cut -f3 -d" "

echo $data |awk -F" " '{print $1}'
echo $data |awk -F" " '{print $2}'
echo $data |awk -F" " '{print $3}'

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is cmd a shell?

1002


What are "c" and "b" permission fields of a file?

1009


State the advantages of shell scripting?

1039


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

1322


I want to connect to a remote server and execute some commands, how can I achieve this?

1012


How to check if a directory exists?

1169


What is a shell made of?

939


How will you find the 99th line of a file using only tail and head command?

2523


Explain about debugging?

1006


What is the command to find out today's date?

1126


How do I stop script errors?

1102


Is shell a part of kernel?

1038


how will you find the total disk space used by a specific user?

1036


Differentiate between ‘ and ” quotes.

1142


What is the equivalent of a file shortcut that we have a window on a linux system?

1105