To select a script name till .ksh or .sh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To select a script name till .ksh or .sh
# 1  
Old 11-26-2011
Network To select a script name till .ksh or .sh

Hi All,
My requirement is to search for a Table Name [or other objects] being used in list of script placed at a dir path :
we are using below command to get the desired result :
Code:
grep -H -i <Table_name> <dir_path>/* -r|awk '{print $1}'| uniq -d

#It gives me below result 
/infa/server/bin/sam/scripts/my_script.ksh:PARAM 
/infa/server/bin/sam/scripts/your_script.sh:VARIABLE

Now my requirement is to get rid of those extra characters after .ksh or .sh. I could get the file_name from above command and redirect the same to temp file and using while loop can get rid of extra characters using ${STRING%.ksh} or ${STRING%.sh} . But there is anything we can append to above command to make it in one shot.
Kindly assist. Any help is appreciated.

Last edited by vbe; 11-26-2011 at 07:04 AM.. Reason: code tags
# 2  
Old 11-26-2011
Ugly but Im a bit tired... and lack of imagination...So I will add after your code:
Code:
grep -H -i <Table_name> <dir_path>/* -r|awk '{print $1}'| uniq -d | cut -d : -f 1

# 3  
Old 11-26-2011
Bug

silly mistake but you made it perfect !!! Thanks my bro !!
# 4  
Old 11-26-2011
Something like this?
-l option will list the files uniquely
-H may not be required
You can avoid the * at the end of <dir_path>
Code:
grep -irl <Table_name> <dir_path>

HTH
--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use a multiple line list with the select command in ksh?

I copied the below program to play around with displaying a list of items using the select command in ksh. When I put all items in the same line, it works fine. I am trying to use multiple lines instead of a single row...my list is too large for a single line. How do I get the line continuation... (3 Replies)
Discussion started by: haganator
3 Replies

2. UNIX for Dummies Questions & Answers

Script that tries to connect via SSH till connection is up

Hey, I need a script that tries to connect via SSH to a remote server and that remote server might not be up yet, so retry until succeed the error message I get if the server is not up yet is: ssh: connect to host 127.0.0.1 port 40001: Connection refused any idea of a good way to do it ? ... (5 Replies)
Discussion started by: OdedOvdat
5 Replies

3. UNIX for Dummies Questions & Answers

Shell Script for displaying the line till the target word

" Script for display sentences with special character" Hi, Could any one share a command how to display a line until my target word. For ex: My file has the content as: select * from db_wrk where col1 < col2 insert into table_name values('1','2','tst','wrk','dev','prod') My target... (10 Replies)
Discussion started by: Kalaiselvi66
10 Replies

4. UNIX for Dummies Questions & Answers

Select the latest dated file-ksh script

Hello all!! I am new here and new in scripting! I want to write a ksh script to select the most recent file from a dir and use it in a variable. I have a directory with files named like: YYYMMDD A basic idea of the script I want to write is #!/usr/bin/ksh latest= latest_dated_file at... (2 Replies)
Discussion started by: chris_euop
2 Replies

5. Shell Programming and Scripting

Select ksh menu question

I am creating a Select menu with a few options and I would like to create a "better" looking interface than just this: 1) Option 1 2) Option 2 3) Option 3 Instead, I would like something like this: *********** * Cool Script * * 1) Option 1 * * 2) Option 2 * * 3) Option 3 *... (2 Replies)
Discussion started by: chipblah84
2 Replies

6. Shell Programming and Scripting

running a script only till a point in a day

how can i run the script if its less than a particular time only in unix. for e.g the script kicks off at 9AM and looks for some file etc. I want to make sure it runs only till 12PM and then succeed the job and proceed regardless if the file exists or not. how can we do this (1 Reply)
Discussion started by: dsravan
1 Replies

7. Shell Programming and Scripting

Awk script to match pattern till blank line

Hi, I need to match lines after a pattern, upto the first blank line. Searched in web and some forums but coulnt find the answer. where <restart_step> = 10 -- Execute query 20 -- Write the contents to the Oracle table 30 -- Writing Contents to OUTPUT... (7 Replies)
Discussion started by: justchill
7 Replies

8. Shell Programming and Scripting

How to introduce delay in Shell Script till a key stroke.

Hi All, How to introduce delay in the Bash/Shell Script till key stroke. Below is the requirement.. 1.Execute set of commands. 2.Display the message echo "press any key to continue" Introduce a delay till key stroke. 3.Execute next set of commands. Thanks in Advance Sunil.K (5 Replies)
Discussion started by: sunilrk07
5 Replies

9. Shell Programming and Scripting

How to print lines till till a pattern is matched in loop

Dear All I have a file like this 112534554 446538656 444695656 225696966 226569744 228787874 113536566 443533535 222564552 115464656 225445345 225533234 I want to cut the file into different parts where the first two columns are '11' . The first two columns will be either... (3 Replies)
Discussion started by: anoopvraj
3 Replies

10. UNIX for Dummies Questions & Answers

select in ksh, any guidance for bash?

I have a file driven menu using the select feature in ksh. I like doing it this way, however I would prefer running a bash. Is there some eqivalent way of doing this in a bash shell? ie select&nbsp;file&nbsp;in&nbsp;*.ascii&nbsp; do typeset&nbsp;-u&nbsp;REPLY if&nbsp;&nbsp;;&nbsp;then... (1 Reply)
Discussion started by: Shakey21
1 Replies
Login or Register to Ask a Question