Computing.Net > Forums > Unix > UNIX Shell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

UNIX Shell script

Reply to Message Icon

Name: smathaiv
Date: February 8, 2006 at 14:02:40 Pacific
OS: Windows 2000
CPU/Ram: 256 MB
Comment:

I have a .txt file that contain any # of lines and 6 tab-delimited fields / line.
I want to write a script that would read each line and assign each field in a line to a specific variable. could someone please help me with this?

thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: February 8, 2006 at 17:44:33 Pacific
Reply:

If you have 6 tab delimited fields, this script should get you started:

!/bin/ksh

OFS=$IFS
IFS=" " # tab character between the double quotes
while read f1 f2 f3 f4 f5 f6
do
echo $f1
echo $f2
echo $f3
echo $f4
echo $f5
echo $f6
done < d.file
IFS=$OFS


0

Response Number 2
Name: wanttobeanonymous
Date: March 19, 2006 at 13:03:55 Pacific
Reply:

Hello,
I've a similar situation. But going one step further, I want a sample script that would add new records to the text file, with a user interface and ask the user a confirmation before saving to the file. Can someone please help me?? thanks!



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Verisign SSL Certificate Awk script variables



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


Sponsored links

Ads by Google


Results for: UNIX Shell script

Unix Shell Script www.computing.net/answers/unix/unix-shell-script/3580.html

Unix shell script runing SQL files www.computing.net/answers/unix/unix-shell-script-runing-sql-files/5286.html

Unix shell script problem... www.computing.net/answers/unix/unix-shell-script-problem/6217.html