![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Apr 2005
Posts: 6
Rep Power: 0
![]() |
Piping in a script
Hello all!
I was writing a simple script to search text files for data using grep and I decided to have a go at writing a script that piped unix commands to grep too. I am having problems though. I think the problem is in the storing of user input in a variable. For example:- If I wanted to store who|grep ^l in a variable called $pipe is the spacing of the command an issue when stored in variables or am I completely off the point? This is my code:-
#!/bin/bash
#Filename: piping : Author: L.Pearce
function pipefunction
{
$pipe
}
echo
echo
echo "Type command in full:"
echo "1. Type unix command you want to pipe to grep."
echo "2. Type the 'pipe' symbol and name of tool you are using."
echo "3. Type the metachars and criteria to search with here:"
read pipe
#:::How can the command stored in that variable be run:::
#------------------------------------------------------------------------
#By calling the function "pipefunction"
pipefunction
echo
echo
echo "The entries above match your search"
echo
echoI get this error:- ./piping: line 8: who|grep: command not found Cheers, Trufla Last edited by trufla; Apr 5th, 2005 at 9:41 AM. |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|