Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


Closed Thread
  Search this Thread
Old 11-03-2010, 04:41 PM   #1
LQ Newbie
Registered: Nov 2010
Posts: 6

Rep: Reputation: 0
Bash script

Hi I've got stuck in bash script. I'm writing a script which searches scripts in entered directory and its subdirectories. Scripts are searched on the basis of the first line e.g.: #!/bin/bash or perl,awk,...
My script should display file name,path and script name.

e.g.: if I enter directory "script" it will display

/home/my/script/ bash
/home/my/script/first/ perl
/home/my/script/second/ bash

I've tried this, but no success:

find $directory_name -exec grep -H -l "bash" '{}' \;

- this searches in whole file not just in first line. I was thinking about this "| head -n 1" but don't know how to implement it
- in addition to this I need to display script name

Thanks for help
Old 11-03-2010, 05:38 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Variables and Mkvextract in a bash script and a good resource for bash help? gohmifune Linux - General 9 04-13-2011 09:37 AM
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 05:11 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 12:10 PM
Strange if statement behaviour when using bash/bash script freeindy Programming 7 08-04-2008 07:00 AM
Bash script to create bash script jag7720 Programming 10 09-10-2007 08:01 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:37 PM.

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