LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 01-28-2004, 06:19 AM   #1
rytrom
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
SciYro
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
rytrom
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
do
(here is a question how to take from $line (that is "key1 val1") the both values separately to call:
ln -s key1 val1)
end
 
Old 01-28-2004, 08:20 AM   #4
aikempshall
Member
 
Registered: Nov 2003
Location: Bristol, Britain
Distribution: Slackware
Posts: 442

Rep: Reputation: 46
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
rytrom
LQ Newbie
 
Registered: Jul 2003
Posts: 27

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

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


Reply


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


All times are GMT -5. The time now is 02:09 PM.

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