From owner-freebsd-questions@FreeBSD.ORG Tue Feb 2 15:02:42 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF4EB106566B for ; Tue, 2 Feb 2010 15:02:42 +0000 (UTC) (envelope-from igorr@canmos.ru) Received: from sta1.canmos.ru (sta1.canmos.ru [89.107.124.11]) by mx1.freebsd.org (Postfix) with ESMTP id 9954E8FC0A for ; Tue, 2 Feb 2010 15:02:42 +0000 (UTC) Received: from sta1.canmos.ru (sta1.canmos.ru [89.107.124.11]) by sta1.canmos.ru (Postfix) with ESMTP id E4BE6127A4A; Tue, 2 Feb 2010 18:02:39 +0300 (MSK) Date: Tue, 2 Feb 2010 18:02:37 +0300 (MSK) From: "Igor V. Ruzanov" To: Stefan Miklosovic In-Reply-To: Message-ID: References: X-GPG-PUBLIC-KEY: 1024D/494AF6DC 2008-03-20 Igor V. Ruzanov X-GPG-FINGERPRINT: A723 B6CC 11ED A4E2 1909 C4DC 6EDE 9089 494A F6DC MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-questions Subject: Re: shell redirection X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Feb 2010 15:02:42 -0000 -----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-----