Find files where filename ends with space


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find files where filename ends with space
# 8  
Old 12-15-2016
Quote:
Originally Posted by API
@RavinderSingh13: I tried it, but it is same output as described: (Test.dat)
RavinderSingh13's response works for me (tested in bash and zsh):

Code:
-0-1- ~/tmp  > echo xx >'ab '
-0-1- ~/tmp  > find . -name '* ' -exec echo '({})' \;
(./ab )

As you can see, I can clearly see the space after ./ab . If you don't see a space with this command, it means that your file doesn't have one at the end.
These 2 Users Gave Thanks to rovf For This Post:
# 9  
Old 12-15-2016
Thanks a lot for your help...

The best solution for me is the hint of ronaldxs:

Code:
IFS=$'\n'
for file in $(find . -name '*\ ' )
do
   echo "($file)"
done

Thats fine for me.

---------- Post updated at 03:59 PM ---------- Previous update was at 03:56 PM ----------

@rovf:

Sorry, but all what I get is:

Code:
({})
({})
({})
({})

---------- Post updated at 04:02 PM ---------- Previous update was at 03:59 PM ----------

@ravf: Ah yes, now I tested it on my Linux machine - there it works as you described!!

The Problem I have is on an AIX...
This User Gave Thanks to API For This Post:
# 10  
Old 12-15-2016
Why is using a for loop better then the solution that has been suggested earlier ?
Code:
find . -type f -name '* ' -exec echo "({})" \;


--
If you insist on the for loop approach,
On AIX, you would need to use:
Code:
IFS="
"


Last edited by Scrutinizer; 12-15-2016 at 12:53 PM..
# 11  
Old 12-15-2016
Some Unix find cannot handle -exec echo "({})"!
My previous post suggested printf. It worked for the current directory only. Likewise the external printf can be used in find
Code:
find . -type f -name '* ' -exec printf "(%s)\n" {} +

Should work on all LUnix.
Comment on the $ quoting: only bash,zsh,ksh93 support the $'\n'.
This User Gave Thanks to MadeInGermany For This Post:
# 12  
Old 12-16-2016
Quote:
Originally Posted by API
Code:
IFS=$'\n'
for file in $(find . -name '*\ ' )
do
   echo "($file)"
done

You wrote the find command differently from what I gave in my example ....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To find files having filename containing specific date format

Hi, I have a requirement to create a shell script(tcsh) that finds all the files in a directory having the file name containing date format "YYYYMMDDHHMM" and extract the date time part ""YYYYMMDDHHMM" for further processing. Could you please have any idea on this. trades_201604040000.out... (6 Replies)
Discussion started by: gopal.biswal
6 Replies

2. UNIX for Dummies Questions & Answers

Find all files containing string not following symlinks CAT (modified) output content to /filename

This should recursively walk through all dirictories and search for a specified string in all present files, if found output manicured content (eg some regex) with CAT into a specified directory (eg /tmp/) one by one, keeping the original names This is what I have so far, which seems to... (1 Reply)
Discussion started by: lowmaster
1 Replies

3. Shell Programming and Scripting

How to find a file which are not ends with ".zip" and which are ends with "*.log*" or "*.out*"?

I am new to bash/shell scripting. I want to find all the files in directory and subdirectories, which are not ends with “.zip” and which are contains in the file name “*.log*” or “*.out*”. I know below command to get the files which ends with “.log”; but I need which are not ends with this... (4 Replies)
Discussion started by: Mallikgm
4 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

Find files greater than a particular date in filename.

I need a unix command which will find all the files greater that a particular date in the file name. say for example I have files like(filenaming cov : filename.YYDDMMSSSS.txt) abc.201206015423.txt abc.201207013456.txt abc.201202011234.txt abc.201201024321.txt efg.201202011234.txt... (11 Replies)
Discussion started by: lijjumathew
11 Replies

6. Shell Programming and Scripting

Perl Script to find the disk usage and to delete the files which is consuming more space

Hi All, I have written a script to check the file system usage and to delete the files which is consuming more space.Please check whether the script is corrcet #Script Starts here #!/usr/local/bin/perl #Program to find the disk space and to delete the older files #Checks the type of OS... (8 Replies)
Discussion started by: arunkarthick
8 Replies

7. UNIX for Dummies Questions & Answers

filename with white space

our user creates a text file with a white space on the filename. this same file is transfered to unix via automation tool. i have a korn shell script that reads these files on a input directory and connects to oracle database to run the oracle procedures which will load the data from each of the... (2 Replies)
Discussion started by: wtolentino
2 Replies

8. UNIX for Dummies Questions & Answers

sort and find duplicates for files with no white space

example data 5666700842511TAfmoham03151008075205999900000001000001000++ 5666700843130MAfmoham03151008142606056667008390315100005001 6666666663130MAfmoham03151008142606056667008390315100005001 I'd like to sort on position 10-14 where the characters are eq "130MA". Then based on positions... (0 Replies)
Discussion started by: mmarshall
0 Replies

9. Shell Programming and Scripting

Filename from splitting files to have the same filename of the original file with counter value

Hi all, I have a list of xml file. I need to split the files to a different files when see the <ko> tag. The list of filename are B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml ... (3 Replies)
Discussion started by: natalie23
3 Replies

10. UNIX for Advanced & Expert Users

Find and store files based on FileName and Modified Time

Hi, I am currently using the following command: files=(ls enuCPU??.????.exp ntuCPU??.????.exp) I need to now change the commmand to store the file names of files that have been modified before datetime equal to say '02/16/2008 20:30:00' What could I use? (2 Replies)
Discussion started by: edisonantus
2 Replies
Login or Register to Ask a Question