LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   help (https://www.linuxquestions.org/questions/linux-newbie-8/help-634117/)

paresh_ec205 04-09-2008 03:44 AM

help
 
for example
this my one file in that i am writing this type
cd /root/Desktop/paresh/dir
xx = 10
name_value=9
gg=3


i want whenever run the my script then i m passing argument(for ex. name_value) then i want display only "9" but i did not get actual out put
see the my script below

#!/bin/sh
cd /root/Desktop/paresh/dir
n1=$1
echo "enter the file name";
read filename;
V=`cat $filename | find . -exec grep "$n1" '{}' \; `
echo $V

acid_kewpie 04-09-2008 04:55 AM

please use useful thread titles in future.

ehawk 04-09-2008 10:34 AM

Also consider posting to justlinux.com, but be aware they are even more insistent upon people using descriptive subject headers for their posts.

http://www.freeos.com/guides/lsst/

http://steve-parker.org/sh/sh.shtml

http://www.cyberciti.biz/nixcraft/li...features/lsst/

http://www.linuxcommand.org/writing_shell_scripts.php

http://linux.dbw.org/shellscript_howto.html

http://www.comptechdoc.org/os/linux/...gshellpro.html

Sorry I cannot be of more help, I have not done much shell scripting.

prad77 04-09-2008 03:49 PM

you can add 'set -x ' at the top of your script to switch debugging on .(set +x for off)

you can try to execute the command within quotes in command line first, to check for proper outpur.

you can use "grep $n1 filename" to search in a file.

http://www.delorie.com/gnu/docs/grep/grep_13.html

Gentoo


All times are GMT -5. The time now is 04:32 PM.