All Questions
10 questions
0
votes
2
answers
783
views
Piping find to xargs works in terminal, but not in shell script [duplicate]
I'm trying to write a Bash shell script that copies all the files in the current directory, minus a few exceptions, into another directory. The script builds a command, stores it in a variable, and ...
0
votes
1
answer
579
views
Command substitution with xargs inputs [duplicate]
I'm trying to write a simple command that will create symlinks for all files in a specific directory (Yes, exactly like lndir but I cannot use it so I try to mimic it).
I tried the following using ...
0
votes
1
answer
332
views
How to run second command only when first is successful when using find and xargs?
My situation is:
I have many files with a name timestep1_i for many values of i and I am trying to combine all the files for timestep1 with a program called combinefiles. I want to do it in parallel (...
1
vote
6
answers
383
views
How could I improve this script which sorts files according to extension?
I have a small script which simply shall go through my Downloads folder and then sort the files according to the extension.
How can I make this cleaner/better? I would like to simply maintain a list ...
1
vote
3
answers
2k
views
How can I use an argument from xargs to evaluate another expression?
I would like to evaluate a basename expression given an argument from xargs.
I tested:
find . -name '*.txt' | xargs -I f cp f DIR_OUT/copied_$(basename f)
which gives no file or directory because $(...
0
votes
2
answers
2k
views
Find with absolute path inside a bashscript | xargs basename
I have to find recursively inside a bash script. Since I can invoke the bash script from anywhere, I am forced to use the absolute path. Sometimes the absolute path can get very long, and the output ...
0
votes
5
answers
147
views
How I delete all files in a directory with specific extensions except the last 5 of them [duplicate]
The directory contains files with different extensions. I would like to delete all files with extensions .gz, zx, ext4 except the last 5 files. I can list all those files with
ls -l | grep '\.gz\|xz\...
4
votes
3
answers
6k
views
Applying bash function to each file in subfolder recursively
I am trying to write a script that will apply a bash function for each file in a directory recursively. For example if the directory tests had all my files and sub-directories in it, the script
find ...
4
votes
3
answers
7k
views
find, xargs and mv: renaming files with double-quotes, expansion and bash precedence issue
Ok, I'm simply trying to strip out double-quotes in my filenames. Here's the command I came up with (bash).
$ find . -iname "*\"*" -print0 | xargs -0 -I {} mv {} {} | tr -d \"
The problem is the 'mv ...
2
votes
2
answers
311
views
Output of command when piped to another command
I am running a command which does a quick checksum of some file like so
find / -type f -ctime +30 -mtime +30 -atime +30 -exec md5sum {} \; | xargs -P 4
and I am trying to run it in parallel with
...