Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input from a file

Status
Not open for further replies.

FredrikN

Programmer
Jan 5, 2001
60
SE
Hi.
Maybe someone can help me with this problem.
Let say I want to run the command cat test.txt grep -v
and then I want to get the rest of the command from some textfile.

I tried
cat test.txt grep -v < textfile.txt

and there are many lines in the textfile
that looks like this
192.168.0.1
192.168.0.2
192.168.0.3

I know I can do this with perl or C but it will be much quicker and easier if the < stuff will work.

Maybe someone can help me with this problem ?

Thanks.
 
Oki, I got it now.
But I have one mor question.

If the textfile looks like this, it's a file with user and their passwords and home dirs.
E.x.

cool -p hithere -b /home/xxx/
fast -p fast -b /home/xxxx/

So if I run
useradd `cat usersfile.txt`
there can only be one user in the textfile.

Is it possible to run the useradd command for each line in the textfile.

I wrote a perl script for this a year ago, but if it could be solved with this stuff I'm talking about it would be great :)

Thanks
 
Hi.
The thing you are writing is the thing I'm trying to do.

But do you know how I can do it from the command promt ??
It's easy from a script but the question is how I can do it from the command promt.

Thanks


 
Hi,
Anything you can do in a script can be done in a command line, since a script is just a list of command lines.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top