Find File with space


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find File with space
# 1  
Old 03-26-2014
RedHat Find File with space

Hello All,

I have path
Code:
 /allcode/mainld/process/recenttmp

where I get many type of file from other platforms. so in UNIX I need to process all file present in this location. but I don't want to process files with the space and delete them.

Please provide your suggestion.
# 2  
Old 03-26-2014
You want to exclude files with space characters in the filename? Or do you mean something else?
# 3  
Old 03-26-2014
RedHat find

Quote:
Originally Posted by CarloM
You want to exclude files with space characters in the filename? Or do you mean something else?

yes you are correct.
# 4  
Old 03-26-2014
Try:
Code:
find /allcode/mainld/process/recenttmp -type f ! -name "* *"

This User Gave Thanks to CarloM For This Post:
# 5  
Old 03-26-2014
RedHat find

Quote:
Originally Posted by CarloM
Try:
Code:
find /allcode/mainld/process/recenttmp -type f ! -name "* *"

this is the way to find them, do you know how to list down all and delete them.


find me it works like this way

Code:
find . -name "* *"

but these files are under sub directories and i dont know the path, is there anyway to delete after find.

---------- Post updated at 10:03 AM ---------- Previous update was at 07:32 AM ----------

I found the solution
Code:
find /path -type f -prune -name "* *" -exec rm {} \;

or 

find /path -type f -prune -name "* *" -exec rm -rf {} \;

in HP UX
# 6  
Old 03-26-2014
Code:
find /path -type f -prune -name "* *" -exec rm -rf {} \;

Extremely dangerous, this will recursively remove a directory's contents.
# 7  
Old 03-28-2014
You may make use of the -printand -delete parameters? e.g.

Code:
[soliton@UAT:test]$ ls -1
s1*
s2*
test file
[soliton@UAT:test]$ find . -type f -name "* *" -print
./test file
[soliton@UAT:test]$ find . -type f -name "* *" -print -delete
./test file
[soliton@UAT:test]$ ls -1
s1*
s2*


Last edited by soliton; 03-31-2014 at 11:10 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing only the first space to a tab in a space delimited text file

Hi, I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

2. Shell Programming and Scripting

sed the find the third , and replace with a space

Dear All, I am new here. Could anyone help to find a sed script for replace the third "," to " "? input: abc,def,ghi,jkl,mno,pqr,stu,vxz output: abc,def,ghi jkl,mno,pqr,stu,vxz Many thanks. Please use code tags next time for your code and data. (2 Replies)
Discussion started by: mimilaw
2 Replies

3. Shell Programming and Scripting

Awk with Find and play using Space

Hi All, Sample records 2157 91128 -rw-r----- 1 arun1 staff 93315072 Aug 23 06:44 /home/arun/my own/file_name.txt 2157 91128 -rw-r----- 1 arun1 staff 93315072 Aug 23 06:44 /home/arun/myown/file name2.txt i want to print only user name, user group, size, date time stamp, and... (5 Replies)
Discussion started by: Arunprasad
5 Replies

4. Red Hat

Help to Find out Available disk space

I need to find available disk space for /home. $ df /home Filesystem 1K-blocks Used Available Use% Mounted on /dev/mahhh/VolGroup11-LogVol00 32281452 45028 26034172 15% / $df /home |tail -1| awk '{print $4}' 15% The above result shows the... (5 Replies)
Discussion started by: Anu_1
5 Replies

5. Shell Programming and Scripting

how to find a job which is writing a big file and eating up space?

how to find a job which is writing a big file and eating up space? (3 Replies)
Discussion started by: rush2andy
3 Replies

6. Red Hat

How do i find free space in my unix?

Hello, I wanted to calculate free space in my unix file system. Here is my direction. I can use df -h command to get the below output. Filesystem Size Used Avail Use% Mounted on =================================================== /dev/vx/dsk/edcdg/data01vol ... (9 Replies)
Discussion started by: govindts
9 Replies

7. Shell Programming and Scripting

find file with space and cksum

find . -type f | xargs cksum this command is failing for the files which has a space in between them any quick solution ? preferably one liner (2 Replies)
Discussion started by: reldb
2 Replies

8. Shell Programming and Scripting

find the folder with space in name.

A solaris server with SAMBA share folder. The PC users created many folders with space on it, I want to find them out, but not list its subfolders. For example, I have below folders Copy of ABC/efg/xy sa/Test again/xyt If I use command: find . -type d |grep " " I will list 6 folders, but... (2 Replies)
Discussion started by: rdcwayx
2 Replies

9. Shell Programming and Scripting

find the free space of a particular directory

Hi Guys, I want to find the free space of a particular directory,, Regards, Magesh (3 Replies)
Discussion started by: mac4rfree
3 Replies

10. UNIX for Dummies Questions & Answers

How to find a file whick is consuming larger disk space in file system

Hello, Can anybody please tell me the command to find out the filesystem or a file which is consuming larger disk space sing i want to find out the file and want to compress it please help me out any help would be appreciated (6 Replies)
Discussion started by: lokeshpashine
6 Replies
Login or Register to Ask a Question

Featured Tech Videos