In earlier articles we have seen awk command to fetch a specific field where we have single character delimiter. Here we will see how can we fetch specific field where data is separated by multi character delimiter.
$ echo "1001***A1***HR***5000" | awk -F'***' '{print $1}'
Output:
awk: There is a regular expression error.
?, *, or + not preceded by valid regular expression
$ echo "1001***A1***HR***5000" | awk -F'[*][*][*]' '{print $1}'
Output:
1001
You can achieve the same by cut command as given below:
$ echo "1001***A1***HR***5000" | cut -d'***' -f1
Output:
1001
Keep Reading, Keep Learning, Keep Sharing...!!
$ echo "1001***A1***HR***5000" | awk -F'***' '{print $1}'
Output:
awk: There is a regular expression error.
?, *, or + not preceded by valid regular expression
$ echo "1001***A1***HR***5000" | awk -F'[*][*][*]' '{print $1}'
Output:
1001
You can achieve the same by cut command as given below:
$ echo "1001***A1***HR***5000" | cut -d'***' -f1
Output:
1001
Keep Reading, Keep Learning, Keep Sharing...!!