Computing.Net > Forums > Unix > Inserting record

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Inserting record

Reply to Message Icon

Original Message
Name: Chinmaya
Date: August 24, 2005 at 23:53:39 Pacific
Subject: Inserting record
OS: HP-UX
CPU/Ram: NIL
Comment:

Hi

I want to insert the record to the beginning of the file not to the end of the file.

If we run operator >>, it appends the record to the end of the file.

Example: Suppose file ‘A’ contains following records

Day 10
Day 20
Day 30

If I run print ‘Day 5’ >> A, file ‘A’ will have records as follows

Day 10
Day 20
Day 30
Day 5

But I want the file ‘A’ should have records in the following order

Day 5
Day 10
Day 20
Day 30.

Could some one please tell me how to achieve this?


Thanks and Regards
Chinmaya


Report Offensive Message For Removal


Response Number 1
Name: vicchai
Date: August 25, 2005 at 07:05:25 Pacific
Reply:

You can achieve this by this script:

#name of the script: addline
#how to use: addline fileA "Day 5"
echo $2 > tempfile
cat $1 >> tempfile
mv tempfile $1


Report Offensive Follow Up For Removal

Response Number 2
Name: Chinmaya
Date: August 26, 2005 at 09:31:05 Pacific
Reply:

Hi Victor.

Thanks a lot for your logic. It worked out.

Thanks and Regards
Chinmaya


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home



Results for: Inserting record

Send mail on UNIX
    Summary: Hi, I have a question. how do we send a mail on one line command?? like it should include the.... recipent, subject, body, I found some sources online but, it doesnt send it right away.. I tried pi...
www.computing.net/answers/unix/send-mail-on-unix/4064.html

need help-sql error
    Summary: Hi, I have a client application- which when trying to access(update/insert) records in an informix database located remotely build on an unix server- i get an error message saying : "SQL error -1227 :...
www.computing.net/answers/unix/need-helpsql-error/6573.html

passing paramters with spaces
    Summary: I am trying to pass variables from a korn script to an oracle stored procedure that sends email. However when I pass the subject or the body of the email to the sql script that calls the procedure, e...
www.computing.net/answers/unix/passing-paramters-with-spaces/6406.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes Today.
Discuss in The Lounge
Poll History






Data Recovery Software