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

  • SEARCH
  • Home
  • 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 4591356
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:23:02+00:00 2026-05-21T22:23:02+00:00

I have a file which has very long rows of data. When i try

  • 0

I have a file which has very long rows of data. When i try to read using shell script, the data comes into multiple lines,ie, breaks at certain points.

Example row:

B_18453583||Active|917396140129|405819121107402|Active|7396140129||7396140129|||||||||18-MAY-10|||||18-MAY-10|405819121107402|Outgoing International Calls,Outgoing Calls,WAP,Call Waiting,MMS,Data Service,National Roaming-Voice,Outgoing International Calls except home country,Conference Call,STD,Call Forwarding-Barr,CLIP,Incoming Calls,INTSNS,WAPSNS,International Roaming-Voice,ISD,Incoming Calls When Roaming Internationally,INTERNET||For You Plan||||||||||||||||||

All this is the content of a single line.
I use a normal read like this :

var=`cat pranay.psv`
for i in $var; do
    echo $i
done

The output comes as:

B_18453583||Active|917396140129|405819121107402|Active|7396140129||7396140129|||||||||18-  MAY-10|||||18-MAY-10|405819121107402|Outgoing  
International  
Calls,Outgoing  
Calls,WAP,Call  
Waiting,MMS,Data  
Service,National  
Roaming-Voice,Outgoing  
International  
Calls  
except  
home  
country,Conference  
Call,STD,Call  
Forwarding-Barr,CLIP,Incoming  
Calls,INTSNS,WAPSNS,International  
Roaming-Voice,ISD,Incoming  
Calls  
When  
Roaming  
Internationally,INTERNET||For  
You  
Plan||||||||||||||||||  

How do i print all in single line??
Please help.
Thanks

  • 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-05-21T22:23:03+00:00Added an answer on May 21, 2026 at 10:23 pm

    This is because of word splitting. An easier way to do this (which also disbands with the useless use of cat) is this:

    while IFS= read -r -d $'\n' -u 9
    do
        echo "$REPLY"
    done 9< pranay.psv
    

    To explain in detail:

    • $’…’ can be used to create human readable strings with escape sequences. See man bash.
    • IFS= is necessary to avoid that any characters in IFS are stripped from the start and end of $REPLY.
    • -r avoids interpreting backslash in text specially.
    • -d $'\n' splits lines by the newline character.
    • Use file descriptor 9 for data storage instead of standard input to avoid greedy commands like cat eating all of it.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an excel file which has more than 65536 rows. However, I can
I have an index.php file which has to process many different file types. How
I have a product which has been traditionally shipped as an MSI file. It
I have a file which is an XML representation of some data that is
I have a .rc file which is used to include some text data in
I have a php file which I will be using as exclusively as an
i have a log file which contains hundreds/thousands of seperate XML messages and need
I have a txt file which actually is a html source of some webpage.
I have a javascript file that reads another file which may contain javascript fragments
Good morning. I have an XML file which contains lists of warning and errors

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.