LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-16-2006, 01:00 PM   #1
jsheffie
Member
 
Registered: Dec 2004
Location: Florida, USA
Distribution: Suse 10.0, OSX.4, Solaris 10
Posts: 163

Rep: Reputation: 30
n-1 a possibility?


Hi,

I am trying write a bash shell script. In this script is a portion that reads lines from an external file using:

for i in `cat $FILEPATH`
do

I am having a little trouble because, even though all items from the file are list in a preview page, only the first line gets implemented.

Does anyone know of a way to do a sort of n - 1 setup where a script will read the first line, apply the second command, re-read the file but ignore the first line and apply the second command... re-read the file but ignore the nth line?

Or is there maybe another option for applying multiple entries to shell commands?

thanks,
-Me
 
Old 05-16-2006, 01:19 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
you really need to explain what you want to do better ... not got a clue what you are after...
 
Old 05-16-2006, 05:39 PM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Guessing a bit here what it actually is you want to do.. but try this:

Suppose you have a file called "file.txt" with this content:
Code:
one: the first line
two: the second line
three: the third line
four: the forth line
Then try this (bash) script:
Code:
#!/bin/bash
while read i ; do
    echo "==> $i"
done <file.txt
 
Old 05-16-2006, 07:12 PM   #4
jsheffie
Member
 
Registered: Dec 2004
Location: Florida, USA
Distribution: Suse 10.0, OSX.4, Solaris 10
Posts: 163

Original Poster
Rep: Reputation: 30
thanks for the responses...

HKO... I will try that first thing in the morning...
acid... I will put up a better description tomorrow morning (EST) when I get back to work (Going out... you know how that is right?).


Thanks for all the help,
-Me
 
  


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
Is this a possibility? SevenForever Linux - Newbie 4 04-26-2005 11:27 PM
possibility of copy from other hdd tomamodi Linux - Newbie 3 04-19-2004 11:38 PM
Linux Possibility unixbrain Linux - Newbie 2 09-23-2003 07:23 AM
Dual monitors are a possibility Poet Linux - Newbie 2 07-24-2003 09:40 AM
Remote Usenet possibility hk342us Linux - Software 0 07-09-2002 12:33 AM


All times are GMT -5. The time now is 08:06 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration