Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Feb 2010 18:02:37 +0300 (MSK)
From:      "Igor V. Ruzanov" <igorr@canmos.ru>
To:        Stefan Miklosovic <miklosovic.freebsd@gmail.com>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: shell redirection
Message-ID:  <Pine.LNX.4.64.1002021738420.25287@sta1.canmos.ru>
In-Reply-To: <f99a79ec1002020502u10cf5040s5a5d8b49f1ff89f@mail.gmail.com>
References:  <f99a79ec1002020502u10cf5040s5a5d8b49f1ff89f@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
-----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@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-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.64.1002021738420.25287>