Remove ./ from result when i do find

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove ./ from result when i do find
# 1  
Old 01-15-2014
Scissors Remove ./ from result when i do find

Hi All,

When i do find command i am getting result which append ./ before the file name. For example if i am trying to search aaa.txt in current directory i am using find like this:

$ find . -name aaa.txt



Now i want to remove "./" from the file name. Can some body help me to update this result?

# 2  
Old 01-15-2014
find ... | sed 's#^\./##'

# 3  
Old 01-15-2014
Hello Vasu,

I don't know any direct command but you can you use Sed command to replace "./" string.

find . -name aaa.txt|sed "s/\.\///g"

# 4  
Old 01-15-2014
Thanks Corona and Srikanth for your quick response, That works.
# 5  
Old 01-15-2014
Or try:
find * -name aaa.txt -print

This User Gave Thanks to Yoda For This Post:
# 6  
Old 01-15-2014
Or, staying entirely in the shell:
[ -e aaa.txt ] && echo aaa.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash to remove find and remove specific extension

The bash below executes and does find all the .bam files in each R_2019 folder. However set -x shows that the .bam extension only gets removed from one .bam file in each folder (appears to be the last in each). Why is it not removing the extension from each (this is $SAMPLE)? Thank you :). set... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Unexplained result of 'find' command

Given this bit of script: retprd=$1 find ${extrnllogdir} -name "*.log" -mtime +$retprd -exec ls -l {} \; >> $logfile produces this (with 'set -x') ++ find /xfers/oracle/dw/data -name '*.log' -mtime +60 -exec ls -l '{}' ';' find: /xfers/oracle/dw/data/cron: Permission denied Where is he... (5 Replies)
Discussion started by: edstevens
5 Replies

3. Shell Programming and Scripting

Remove a character and assign result to a variable

I am reading lines from a file that contain a number sign (#) before a three or four digit number: #1043 #677 I can remove the '#' and get just the number. However, I then want to assign that number to a variable and use it as part of a path further on in my program: /mydir/10/1043 for... (5 Replies)
Discussion started by: KathyB148
5 Replies

4. UNIX for Dummies Questions & Answers

Find command - result order

Hi! Could you please explain why the result order isn't in reverse time order as it is requestet by "xargs ls -ltr" command (ksh shell)? There are about 5000 files in dir. $ find . -name "*201010*" -print |xargs ls -ltr |tail -rw-r--r-- 1 oracle oinstall 54326 Nov 25 20:32... (2 Replies)
Discussion started by: laki47
2 Replies

5. Shell Programming and Scripting

Find result using for loop

I want to print each file i found using the find command. And not able to list the files at all here is the code SEARCH_DIR="/filesinfolder"; PATH_COUNT=0 for result in "'/usr/bin/find $SEARCH_DIR -daystart \( \( -name 'KI*' -a -name '*.csv' \) -o -name '*_xyz_*' \) -mtime 1'" do... (1 Reply)
Discussion started by: nuthalapati
1 Replies

6. Shell Programming and Scripting

How to remove space in between the result

Hi All, How do i remove the spaces in between, the outputted result: my output is like below and i dont want spaces between them, how do i do that. I am enclosing the peice of code that does that:- if ; then $ECHO "The Path is:" $OFFERING_FILE_PATH/$z $ECHO $Z else $ECHO "" fi... (10 Replies)
Discussion started by: asirohi
10 Replies

7. UNIX Desktop Questions & Answers

find result

When searching for some files which match some specific criteria with find from the root directory, I got a listing of a bunch of files that say "Permission Denied". How can do my search and not show the files that I don't have the permission to list? Thanks, (3 Replies)
Discussion started by: Pouchie1
3 Replies

8. Shell Programming and Scripting

sh : Problem with the result of a find command

Hi I'm working on solaris and I'm trying to run a script. The part listed here does not work properly, the result of the find command is not in the output file /tmp/result (I've checked the find command , executing the shell with sh -x , it seems correct). It seems like I've lost the standard... (4 Replies)
Discussion started by: frenchwill
4 Replies

9. Shell Programming and Scripting

result of find

Hey, I am using 'find' to check the existence of a file which is created today, and this is what I have find . -name $filename -mtime +0 -exec ls {} \; my problem is I need to know what the above command actually get anything, so can anyone give me some pointer on how to do... (1 Reply)
Discussion started by: mpang_
1 Replies

10. UNIX for Advanced & Expert Users

find command not returning any result

I am looking for all the header files (*.h).. which as per documentation of the UNIX system shouldbe there. I am using find / -name *.h -print But it does't give anything. My question is under what condition the "find" condition will fail to find the file? What is the work around. ... (4 Replies)
Discussion started by: rraajjiibb
4 Replies
Login or Register to Ask a Question