Character, stirng, word delimiter search and split using shell scripts

by rajesh 2014-05-13 12:03:18

Delimiter based search and split can be done using the follwing commands.

If you want to use a single character as delimter to split a string, you can use cut command
 cut -d'.' -f1 string
this will split the string using delimiter . (dot) and print first portion of the delimited string.

another example:
cut -d',' -f2 asd,ff,gg
this will print ff as output. If you want to use a word or string as delimiter then you can use awk command
awk -F "div" {print $3} file.txt
1261
like
0
dislike
0
mail
flag

You must LOGIN to add comments