Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-28-2004, 06:19 AM   #1
LQ Newbie
Registered: Jul 2003
Posts: 27

Rep: Reputation: 15
Shell script question

I have a text file containing pais of strings. I need for each pair create a link like:

ln -l word1 word2

How can I parse the file and execute the command in a script?
Old 01-28-2004, 07:55 AM   #2
Senior Member
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
i dono, at the top of a script file it should read
/bin/sh (wich should be a symlink to your shell, most likly bash)
tehn type a list of comands to follow in here
then save it then giv it executable permisions i think it is (chmod 733 ./(ur sctips name that you saved it as) )
then that sould do it i think, but if ya want some advise dont trust me , and be very carful with that chmod comand as it can make your system unsecure when misused)
Old 01-28-2004, 08:09 AM   #3
LQ Newbie
Registered: Jul 2003
Posts: 27

Original Poster
Rep: Reputation: 15
I'll ask more concrete. I have a file data.txt containing

key1 val1
key2 val2

I have a script:

cat "data.txt" | while read line
(here is a question how to take from $line (that is "key1 val1") the both values separately to call:
ln -s key1 val1)
Old 01-28-2004, 08:20 AM   #4
Registered: Nov 2003
Location: Bristol, Britain
Distribution: Slackware
Posts: 729

Rep: Reputation: 92
Try the following where TheFileofNames contains

word1 word2
word3 word4
word5 word6

cat TheFileOfNames | xargs -n2 ln -l
Old 01-28-2004, 08:20 AM   #5
LQ Newbie
Registered: Jul 2003
Posts: 27

Original Poster
Rep: Reputation: 15
I found:-) RTFM.

cat "data.txt" | while read key val
ln -s $key $val


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script question Whiteghost Programming 17 09-10-2005 07:52 PM
Shell script question paraiso Linux - Newbie 2 05-15-2005 02:55 AM
Shell script question... defa0009 Linux - General 7 04-26-2005 09:16 PM
shell script question Axion Programming 4 07-29-2004 10:51 PM
Shell script question. siaful Linux - Newbie 1 04-29-2004 06:01 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration