Thursday, 4 August 2016

How To Fetch Specific Field In Multi Character Delimiter File Using AWK

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...!!

3 comments:

  1. We have been following your blog for a log. Your work is good
    Please check this Subway Street Run
    Thanks

    ReplyDelete
  2. You have written an excellent blog.. keep sharing your knowledge...
    Cloud Computing Google
    Google Cloud Service

    ReplyDelete
  3. Excellent post, warehouse automation for retail thankful to all your team for sharing such best information.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...