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...!!
We have been following your blog for a log. Your work is good
ReplyDeletePlease check this Subway Street Run
Thanks
You have written an excellent blog.. keep sharing your knowledge...
ReplyDeleteCloud Computing Google
Google Cloud Service
Excellent post, warehouse automation for retail thankful to all your team for sharing such best information.
ReplyDelete