Hi,
I have a problem with a simple script I am trying to write. I want a user to type grep, sed commands that are then stored in variables. Those variables are stored in a function, and the function is then called to execute the commands. The idea is that the user does it step by step.
script:-
#!/bin/bash
#Filename: variabletest : Author: L.Pearce
function tptfunction
{
$tool $criteria $filename
}
echo
echo
echo "Type command in full:"
echo "1. Type the tool you are using."
read tool
echo "You typed $tool"
echo "2. Type criteria you wish to search."
read criteria
echo "You typed $criteria"
echo "3. Type the name of the file you are searching:"
read filename
echo "$filename is what you typed."
tptfunction
echo
echo
I type sed '/Pearce/p' NewFile
the error:-
sed: -e expression #1, char 1: Unknown command: `''
When I type this command, and other similar ones where quotes are used:-
sed -n '/Pearce/p' NewFile
ls | grep '^g'
I get similar errors, like command not found.
I have the saem problem when trying to pipe unix commands to grep or sed
who|grep ^l
I have used:-
grep -n Name NewFile
and this seems to work fine.
I am guessing the spacing is not an issue, moreover the quotes or syntax.
Can anyone help?
Trufla