Bash Split String (Separate or Cut)

In Linux systems and Bash environment we can use many different commands for this purpose ; for example see the followings :

$cut example : echo “my,name,is,iman” | cut -d’,’ -f2 result : name ; it means column number 2 seprated by “,”

$awk example : echo “my name is iman” | awk ‘{print $4}’ result : iman ; it means columns number 4

One of the important thing you have to know ; pipe “|” is used for connectivity between two commands and send StdOut from the first command as a StdIn to the second command

Leave a Reply

Your email address will not be published. Required fields are marked *