Only filename from find command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Only filename from find command
# 1  
Old 04-02-2012
Only filename from find command

Hi All
When we use find command command in Unix we get the result as
/home/user/folder/filename1
/home/user/folder/filename2
/home/user/folder/filename3

Is it possible that i only get the file name
The expected output when using find command is
filename1
filename2
filename3

I am seeking any switch in find command that display only file name
# 2  
Old 04-02-2012
Code:
 
your find command | awk -F/ '{print $NF}'

# 3  
Old 04-02-2012
pipe it to
Code:
awk -F"/" '{print $NF}'

or
Code:
basename ` find command `


Last edited by ningy; 04-02-2012 at 06:48 AM..
# 4  
Old 04-02-2012
I Can't use the awk command.

---------- Post updated at 04:55 AM ---------- Previous update was at 04:51 AM ----------

When using this
basename ` find command `It gives the blank result
# 5  
Old 04-02-2012
can you post your find command.
# 6  
Old 04-02-2012
Code:
 basename `find /home/user/folder -newer /home/user/logs -type f`

# 7  
Old 04-02-2012
Try
Code:
find /home/user/folder -newer /home/user/logs -type f | xargs -L1 basename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find command with Metacharacter (*) Should match exact filename

Hi, Below is list of files in my directory. -rw-rw-r--. 1 Roots Roots 0 Dec 26 06:58 12345_kms_report.csv -rw-rw-r--. 1 Roots Roots 0 Dec 26 06:59 12346_kms_report.csv -rw-rw-r--. 1 Roots Roots 0 Dec 26 06:59 12347_kms_report.csv -rw-rw-r--. 1 Roots Roots 0 Dec 26 06:59... (2 Replies)
Discussion started by: Balraj
2 Replies

2. UNIX for Dummies Questions & Answers

How to find a filename of a folder?

Hi, Please help me i have a file directory in .txt. inside this directory is a list of names of folders to find inside in a folder. to make more easy to understand below is my list inside .txt: foldernameA foldernameB foldernameC I need to check if those folder names are inside... (1 Reply)
Discussion started by: cmarzan
1 Replies

3. Shell Programming and Scripting

Print filename/dir name while executing aclput using find command

Running below command , but unable to print the filename , is there way to print filename/dirname using -print option find . -type f -exec aclput -i fileacl.template {} \; (5 Replies)
Discussion started by: lalitpct
5 Replies

4. Shell Programming and Scripting

Find command error having space in filename

Hi, I am working in solaris.I am using below script to copy the files from /usr/tmp to /usr/gm But while running this it is not considering the files list after the filename having space in them. Example:- compile_custom_pll.sh conv_data_sqlload.sh conv_sqlload.sh Copy of... (5 Replies)
Discussion started by: millan
5 Replies

5. Shell Programming and Scripting

Truncate filename using find

I have a script that executes the following code and I could use some help. find $searchdir -maxdepth 2 -type d -name $dir -exec mkalias {} ./$dir/_$dir$suffix \; (mkalias is an executable to create mac aliases) (The script takes a directory name finds that same name on another drive and... (5 Replies)
Discussion started by: scribling
5 Replies

6. Shell Programming and Scripting

Howto get only filename from find command in Linux?

Hi every body! I would like to get only filename in the result of find command in Linux but I don't know howto. Tks so much for your helps. (5 Replies)
Discussion started by: nguyendu0102
5 Replies

7. Shell Programming and Scripting

how to get only filename in a recursively find command

Hi i would like to ask on how to accomplish the FF: I want to execute a find command recursively and only get the filename something like i want only the last field set if is used ever the fieldvset as an redirection from the output of the find command For example: dir1/dir2/filename1... (2 Replies)
Discussion started by: jao_madn
2 Replies

8. Shell Programming and Scripting

Find filename in the given directory

Hi , I have question for search the filename in directory. For example my DIR contains these files... testA123.txt testB123.txt testB345.txt testA345.txt i want to show the filenames which contains 'testA7'... Help me (7 Replies)
Discussion started by: karthinvk
7 Replies

9. UNIX for Dummies Questions & Answers

help to find find filename usingFile pointer in c

Hi .. I am having a file pointer .. it have declared some where tough to find out that ..Can we find out the filename associated with file pointer ... i mean is there any function FILEPOINTER.filename() is there in c ??... Thanks, Arun (2 Replies)
Discussion started by: arunkumar_mca
2 Replies

10. UNIX for Dummies Questions & Answers

search for hardlinks based on filename via find command

I am using command substitution into a find command in a script where I have built a menu to do a bunch of tasks within my unix account. When I choose the options for to find a file/files that have the same inode of the entered filename, ie hardlinks, nothing shows up. When I choose the appropiate... (2 Replies)
Discussion started by: hunternjb
2 Replies
Login or Register to Ask a Question