1
vote
2answers
2k views

How do I get absolute path from using find unix command

How to get absolute path by using find command. actually I am running the following script:- find . -size +20M | while read a do i=$(echo $a | sed 's:/: :g') echo $a; j=($i) ...
3
votes
3answers
3k views

Why can't find -regex match a newline?

Why does this fail? touch "$(printf "a\nb")"; find . -regex './.\n.' I also tried these, none of which work: find . -regextype posix-extended -regex '.\n.' find . -regextype posix-awk -regex ...
3
votes
4answers
291 views

Use basename to parse a list of paths held in a file

I'm running Mac OSX and trying to use the command line to find the number of files I have with the same name. I tried to use the following command: find ~ -type f -name "*" -print | basename | sort ...
0
votes
2answers
100 views

Handling files with whitespace in their names

I have a lot of files that I need to sift through, specifically grep for certain keywords IN THE FILE, not he FILENAME. I have some 300+ files on a filesystem (so the files are within multiple ...
9
votes
3answers
1k views

identify files with non-ASCII or non-printable characters in file name

In a directory size 80GB with approx 700,000 files, there are some file names with non-English characters in the file name. Other than trawling through the file list laboriously is there: An easy ...
3
votes
3answers
424 views

How to find file/directory names that are the same, but with different capitalization/case?

How can I list the file/directory names in a directory recursively that are the same, but with different capitalization/case? ex.: INPUT (not the ls command, the directories): [user@localhost ...
2
votes
1answer
73 views

find doesn't return expected files

I'm doing a search for files that contain ".anki" in their file name. root@t500:/home/some1# find / -name .anki /home/some1/.anki But there are other files in my home folder that contain .anki: ...
1
vote
2answers
2k views

Command to find file/path lengths that are too long for burning to DVD?

I'm trying to burn a DVD from Windows but it fails because the full path name length exceeds the limit of something like 255 characters. Our files are stored in Debian Linux (accessed by Windows ...
4
votes
3answers
2k views

Manipulate file name piped from find command

I'm relatively new to Bash and am trying to do something that on the surface seemed pretty straightforward - run find over a directory hierarchy to get all of the *.wma files, pipe that output to a ...
2
votes
4answers
1k views

chown all files based on file name pattern in current directory

I'm trying to chown all files whose filenames begin with ChownFileNames. I've used this command, but it doesnt seem to work: find . -maxdepth 1 |grep 'ChownFileNames*' -exec chown hadoop:hadoop -- {} ...
3
votes
2answers
935 views

How do I find a bunch of files with a string in its filename (or body text) and then move all those files to a specific folder?

Say - what if I wanted to move every HTML file in several independent directories with the word "heavengames" in its filename (and as a second question, every HTML files with the word "heavengames" in ...
7
votes
2answers
3k views

How can you move (or copy) all files to a directory with the same filename prefix?

Using Bash So let's say I have a bunch of files randomly placed in a parent directory ~/src, I want to grab all the files matching a certain suffix and move (or copy) them to a ~/dist directory. ...
5
votes
3answers
2k views

How store in a variable a file list that includes the backslash when needed?

Main question: I am writing a script to perform a backup. I make a list of files in the following way: LISTOFFILES=$(find ~ \( -name '*.[pP][dD][fF]' -o -name '*.[oO][dD][tT]' \)) The variable ...
3
votes
1answer
2k views

Rename All Files with a Certain Name

I'm trying to find certain files with the name "stringx" and replace the name (but not the extension) with "stringy". So basically for stringx.txt and stingx.cs, I'd want stringy.txt and stringy.cs. ...
2
votes
3answers
2k views

create md5 hash from a recursive file listing when some paths have spaces

I need to create an md5 hash of every directory and file inside of one main directory. The only thing that is keeping me from success is figuring out a way around files with a space in the path. I am ...
4
votes
4answers
520 views

Find files without a number

I am trying to write a simple script that will iterate through all drives except sda. Right now I have this for i in $(find /dev/ -name "sd*" ! -name "sda*") do echo $i done However this ...
7
votes
3answers
1k views

Is it possible to nest a 'find -exec' within another 'find -exec'?

Something like the following is what I what I'm after, but my code doesn't work, no matter how I escape {} and + ; find ./ -maxdepth 1 -type d -name '.*' -exec \ find {} -maxdepth 1 -type f ...
7
votes
4answers
543 views

How can I find a file whose name includes a given string, such as “abcde”?

Within a set of directories, how do I find a file whose name includes a given string, such as "abcde"?
4
votes
3answers
4k views

How to find files in subdirs and sort them by filename in a single command?

Result of a normal find using find . ! -path "./build*" -name "*.txt": ./tool/001-sub.txt ./tool/000-main.txt ./zo/001-int.txt ./zo/id/002-and.txt ./as/002-mod.txt and when sorted with sort -n: ...
34
votes
8answers
45k views

Looping through files with spaces in the names?

I wrote the following script to diff the outputs of two directores with all the same files in them as such: #!/bin/bash for file in `find . -name "*.csv"` do echo "file = $file"; diff ...