Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7782041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:25:00+00:00 2026-06-01T19:25:00+00:00

I am trying to split the string in a file based on some delimiter.But

  • 0

I am trying to split the string in a file based on some delimiter.But I am not able to achieve it correctly… Here is my code below.

awk 'var=split($2,arr,'\'); {print $var}' file1.dat

Here is my sample data guys.

Col1 Col2
abc  123\abc
abcd 123\abcd

Desire output:

Col1 Col2
abc  abc
abcd abcd
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:25:03+00:00Added an answer on June 1, 2026 at 7:25 pm

    Sample data and output is my best guess at your requirement

     echo '1:2\\a\\b:3' | awk -F: '{ 
         n=split($2,arr,"\\")
         # print "#dbg:n=" n
         var=arr[3]
         print var
         }'
    

    output

    b
    

    Recall that split returns the number of fields that it found to split. You can uncomment the debug line and you’ll see the value 3 returned.

    Note also that for my test, I had to use 2 ‘\’ chars for 1 to be processed. I don’t think you’ll need that in a file, but if this doesn’t work with a file, then try adding extra ‘\’ as needed to your data. I tried several variations on how to use ‘\’, and this seems the most straightforward. Others are welcome to comment!

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to split a string on its punctuation, but the string may contain
I'm trying to split a string into a int list for further processing. But
I have a string: [\n['-','some text what\rcontains\nnewlines'],\n\n trying to parse: Regex.Split(@[\n['-','some text what contains
So I've written some code in Ruby to split a text file up into
I'm trying to split a file with a list comprehension using code similar to:
Trying to split this string 主楼怎么走 into separate characters (I need an array) using
I am trying to split a string in Javascript using a Regular Expression. My
i am trying to split the string to multilines when tweeting using the twitter
So I'm trying to split just a string I've read in through a csv
I am trying to split the single string in to two lines using \n

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.