Today i am showing a way to cut specific word from a string in linux shell script,
lets u have a file such as
we can now simply use,
-->
lets u have a file such as
Alex Farguson manchester united coach 1987-2013
now we want to get only the year when he started his job, that is 1987, say the file name is coach.txtwe can now simply use,
cat coach.txt | awk '{ print $6 }' | cut -f1 -d"-"
cat coach.txtwill print the contents of the file tostdout.awk '{ print $6 }'will print the sixth column, i.e. the one containing1987-2013cut -f2 -d"-"will cut the output of previous step using-as the delimiter and get the first column (-f1)
