shell redirection

Igor V. Ruzanov igorr at canmos.ru
Tue Feb 2 15:02:42 UTC 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 2 Feb 2010, Stefan Miklosovic wrote:

|hi
|
|I have a shell script and I would like to do something like this
|
|$ ./script.sh < somefile
|
You could do kind of the following things:

example.sh:
#!/bin/sh

read new < /dev/stdin
echo $new

After your script was created, you could run it with some redirected 
text file:

./example.sh < file.txt

Don't forget about permissions of your script file to enable script 
execution. Also you might use while/for-expressions if content of the text 
file is multiple strings rather than just a big one.

+-------------------------------------------+
! CANMOS ISP Network                        !
+-------------------------------------------+
! Best regards                              !
! Igor V. Ruzanov, network operational staff!
! e-Mail: igorr at canmos.ru                   !
+-------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: For info see http://quantumlab.net/pine_privacy_guard/

iD8DBQFLaD6Pbt6QiUlK9twRAhbCAJ4iXYyu5SZqc2uGQsg2tkzsIub+iACgv5l0
0RrvgPbvlfKc6HYm06MnWRk=
=4wLL
-----END PGP SIGNATURE-----


More information about the freebsd-questions mailing list