how to grep a file in list


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to grep a file in list
# 1  
Old 06-26-2009
Question how to grep a file in list

hi all,

for an example:
In a file out.txt contains:
/export/home/raghu/bin/debug_serverLog_apache_20090626_0625.txt


How to grep or cut the value as "debug_serverLog_apache_20090626_0625.txt"
or i want only the output as "debug_serverLog_apache_20090626_0625.txt"
pls advice me

Last edited by raghur77; 06-26-2009 at 08:19 AM..
# 2  
Old 06-26-2009
man basename
# 3  
Old 06-26-2009
Code:
basename $(ls -rt /export/home/raghu/bin/debug_serverLog_apache_*.txt | tail -1)

# 4  
Old 06-26-2009
thanks a lot!!! jim mcnamara
its working fine now...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep and ignore list from file

cat /tmp/i.txt '(ORA-28001|ORA-00100|ORA-28001|ORA-20026|ORA-20025|ORA-02291|ORA-01458|ORA-01017|ORA-1017|ORA-28000|ORA-06512|ORA-06512|Domestic Phone|ENCRYPTION)' grep -ia 'ORA-\{5\}:' Rep* |grep -iavE `cat /tmp/i.txt` grep: Unmatched ( or \( Please tell me why am i getting that (6 Replies)
Discussion started by: jhonnyrip
6 Replies

2. Shell Programming and Scripting

List creation - Grep a line in a file with a script name

Hi, I have a list file which has script names in them. Some scripts take lists as parameters which inturn have script names. This is basically for sequencing the job run. Eg: List1: test1.ksh test2.ksh test2.lst test3.ksh test3.lst test4.ksh test2.lst: test21.ksh test23.ksh... (7 Replies)
Discussion started by: member2014
7 Replies

3. UNIX for Dummies Questions & Answers

Grep -B used with -f? (Searching a file using a list of terms, output is lines before each match)

(1 Reply)
Discussion started by: Twinklefingers
1 Replies

4. Shell Programming and Scripting

Using perl to grep a list of patterns from an input file

I have been struggling to grep a file of NGrams (basically clusters of consonants or Consonant and Vowel) acting as a pattern file from an Input file which contains a long list of words, one word per line. The script would do two things: Firstly read a text pattern from a large file of such... (5 Replies)
Discussion started by: gimley
5 Replies

5. Shell Programming and Scripting

Grep -v contents of a list file from another file.

Hello, I am trying to get output from FILE2 that excludes servers from list FILE1. I've tried a for loop with no success. Any ideas how to go about this? FILE1 contains: server1 server2 server3 server4 server5 FILE2 contains: server1:ERROR:user1: error message... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

6. Programming

How to grep the specific string or user's list from the file

I have a file on UNIX system from where I want to grep the list of all users associated to the particular repository.If the user's list is in single line then I fetch all list but if it is in two separate lines it doesn't.I use the below command a=KESTREL-DEV;b=users;cat access_file|grep... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

7. UNIX for Dummies Questions & Answers

How to list file names instead of lines when grep a gzcat command?

Hi, I want to list filenames instead of lines when i search in compresed files for a string. #gzcat *.gz | grep -l 12345 gives me: <stdin> Anyone got a solution on this problem? (2 Replies)
Discussion started by: HugoH
2 Replies

8. Shell Programming and Scripting

find grep and list file name

find . -exec grep "something" {} \; this command only show the grep data but doesn't show the file name and path, how to show file path in this command? (4 Replies)
Discussion started by: bill.zheng
4 Replies

9. Shell Programming and Scripting

Can we grep a list of all running PIDs in a file !!??

Hi, In the following part of a script, I am grepping the list of all running PIDs in the File as in line 3 :- $pid_count=`grep -c "^${pid_process}$" $CRI_PUSH_BIN_HOME/bin/ PushProcessId` If I cannot grep this way, then how can I do so. 1 pid_process=`ps -ef -o pid,args |... (1 Reply)
Discussion started by: marconi
1 Replies

10. UNIX for Dummies Questions & Answers

How will you list only the empty lines in a file (using grep)

How will you list only the empty lines in a file (using grep) (1 Reply)
Discussion started by: JosephGerard
1 Replies
Login or Register to Ask a Question