LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-09-2008, 03:44 AM   #1
paresh_ec205
LQ Newbie
 
Registered: Mar 2008
Posts: 1

Rep: Reputation: 0
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
 
Old 04-09-2008, 04:55 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
please use useful thread titles in future.
 
Old 04-09-2008, 10:34 AM   #3
ehawk
Senior Member
 
Registered: Jul 2003
Posts: 1,257

Rep: Reputation: 48
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.
 
Old 04-09-2008, 03:49 PM   #4
prad77
Member
 
Registered: Mar 2008
Posts: 101

Rep: Reputation: 15
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

Last edited by prad77; 04-17-2008 at 03:45 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration