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 6967985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:23:34+00:00 2026-05-27T16:23:34+00:00

I am trying to read a file which has several lines and print it

  • 0

I am trying to read a file which has several lines and print it as it is.
But my new line in IFS is not working as expected. This is in AIX.

Below is my script,

#!/bin/ksh

#set -x
old_IFS=$IFS      # save the field separator
IFS=$'\n'
LABELFILE=/home/david/label.txt
OUTPUT_FILE=/home/david/label_out.txt

for i in $(cat $LABELFILE)
do
echo "$i" >> $OUTPUT_FILE
done

label.txt

Hello nancy
naghu naghu
Hello navy
You are naughty
Good niece

My Output file(label_out.txt->

Hello
a
cy

aghu
aghu
Hello
avy
You are
aughty
Good
iece

Expected output->

Hello nancy
naghu naghu
Hello navy
You are naughty
Good niece
  • 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-27T16:23:34+00:00Added an answer on May 27, 2026 at 4:23 pm

    Try:

    IFS='
    '
    

    (Just a carriage return there, no extra whitespace.)

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

Sidebar

Related Questions

I'm trying to read and handle a web-page in Python which has lines like
I am trying to read a 12MB+ file which has a large HTML table
I am trying to read a config file which has some key value pairs
I am trying to read a file of over 1GB (which has 1,157,421,364 bytes),
I am trying to read a html file which is a plain page with
I have an xml file(from federal government's data.gov) which I'm trying to read with
I'm trying to read a file to produce a DOM Document, but the file
I'm trying to read a file line by line to a string type variable
I'm trying to read a file from a local filesystem. I do not have
Hi in my project I've to read a .bin file which has sensor data

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.