LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 12: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, 12:19 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

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

Rep: Reputation: 111Reputation: 111
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, 06: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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:11 AM.

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
Open Source Consulting | Domain Registration