LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   variable substitution results in "command not found" error (https://www.linuxquestions.org/questions/linux-newbie-8/variable-substitution-results-in-command-not-found-error-4175496294/)

mj8570 02-26-2014 11:49 AM

variable substitution results in "command not found" error
 
find /data/backup/ -name 20140202* -exec awk -F"|" '$23!=0 {print"|"$14"|"$23}' {} \; > Day1.txt

host='XX.XX.XX.XX'
user='root'
passwd='root'
(
echo "$user"
echo "$passwd"
echo "cd /data/"

echo "find /data/backup/ -name rec20140202* -exec awk -F"|" '$23!=0 {print"|"$14"|"$23}' {} \; > Day2.txt"

echo "exit" )| telnet "$host"

===========================
in the above code fragment second find command ( inside telnet part)is not working. I am getting an error as below
===========================
server2:/data # testnew.sh: line 27: '3!=0 {print: command not found
testnew.sh: line 27: 4: command not found
testnew.sh: line 27: 3: command not found
testnew.sh: line 27: }' {} \; > Day2.txt: command not found
Connection closed by foreign host.


Pls help

pingu 02-26-2014 01:15 PM

Look carefully at that line, check the double-quotes!
What you want is to wrap the whole line in double-quotes, but actually the first enclosed is "find /data/backup/ -name rec20140202* -exec awk -F"

mj8570 02-27-2014 10:55 AM

Thank you very much pingu!

Use of escape (\) preceding character for (") and ($) has solved the issue.

Regards,

- Sharath


All times are GMT -5. The time now is 10:15 PM.