Questions tagged [exec]
74 questions
52
votes
9 answers
How to combine the 'tar' command with 'find'
The find command gives this output:
[root@localhost /]# find var/log/ -iname anaconda.*
var/log/anaconda.log
var/log/anaconda.xlog
var/log/anaconda.yum.log
var/log/anaconda.syslog
var/log/anaconda.program.log
var/log/anaconda.storage.log
After…
max
- 4,163
42
votes
4 answers
How can I run an untrusted executable on linux safely?
I have downloaded an executable compiled by a third party and I need it to run on my box (Ubuntu 16.04 - x64) with full access to HW resources such as CPU and GPU (through nVidia drivers).
Suppose this executable contains a virus or backdoor, how…
Emanuele
- 781
17
votes
1 answer
Batch run mogrify including subdirectories
The command mogrify -format jpg *.NEF when run in a directory converts all *.NEF files to JPEGs. What I want to do is to be able to run mogrify in *.NEF files inside subdirectories as well using one command. I am trying to run something like:
find…
Regmi
- 855
9
votes
2 answers
Perrmission to run specific command by sudo as www-data users without password
I have a webserver that also plays internet radio. As www-data user I want to run some commands, for example I've made this in /etc/sudoers file:
www-data ALL=(ALL) NOPASSWD: /usr/bin/amixer
And form PHP I can manipulate volume without using…
Peter
6
votes
2 answers
Why does sudo fork before executing the process?
This question may seem a bit silly, but since in Unix-based systems, replacing an executable's image is done in a single step, replacing the currently running process, in the function call execve (and derivatives), the question is:
Why does sudo…
ssice
- 964
5
votes
2 answers
Redirection or pipe inside `find -exec`
Any "find -exec" guru's around.
I have a folder of files I need to send to sendmail (they appear in there when something bad has happened).
The command
find . -type f -exec sendmail -t < {} \;
gives me
-bash: {}: No such file or directory
It…
Richard
- 53
3
votes
2 answers
How to execute files which are found by find
I have some executable files under a directory tree. I want to find them and execute them the most simple way.
I've tried this so far:
find . -perm 0775 -type f | xargs exec
But exec is not an executable, it is a bash internal.
I could create a…
Gabor Marton
- 777
3
votes
4 answers
Is there a way to use > operator in find -exec
I'm trying to empty lots of files under a certain folder.
>file or cat /dev/null > file or echo "" > file can empty file.
find . -type f -exec blahblah {} \; can find files and do something on them.
I tried to use the > operator in find ... -exec…
Sencer H.
- 1,390
3
votes
3 answers
Argument list too long for xargs/exec
I'm working on a CentOS server and I have to move around and cat together millions of files. I've tried many incarnations of something like the below, but all of them fail with an argument list too long error.
command:
find ./ -iname out.* -type f…
ohblahitsme
- 143
3
votes
2 answers
Why is find exec grep > file an Infinite Loop?
I was trying to collect all of the Message-ID: headers (lines) in a directory with 200K .eml (plain text) files. A bit naively, I said:
find -type f -exec grep -Fi "message-id:" {} \; > messageids.txt
I let it run overnight, since I figured it…
Hammer Bro.
- 389
2
votes
1 answer
Construct command for bash exec
I have a shell script that runs exec to replace itself with another command. The other command takes some optional arguments.
exec mycommand $ARG1 $ARG2 $ARG3
Any of these arguments could be populated or not populated. If they aren't populated,…
Nick Retallack
- 2,086
2
votes
1 answer
Linux find command with multiple command -exec using chown and chmod
The following command runs but the two -exec commands don't run - so the file gets moved but the permissions and file owner doesn't change.
find ~/Downloads/ -name "2014-12-24*"
-exec sudo mv {} ~/docs/ \;
-exec sudo chown {} apache:apache \;
…
2
votes
2 answers
How to make a copy of file in the same directory
This creates a file in the same directy as 'some.file.bak'.
find /home/ -ipath "*/temp/some.file" -type f -exec cp {} {}.bak \;
How to make a copy in another name such as 'another.file' in the same directory as some.file instead of…
13th Matrix
- 73
2
votes
1 answer
Pass result of the command to exec
I have a kind of "bash newbie" question: how do I pass the result output of one command to exec. The result of the first command is the name of other command, so exec should be able to execute it.
lwt
- 23
2
votes
2 answers
ffmpeg working when SSH but not when PHP exec
I am not sure why so first here is the error
Array ( [0] => ffmpeg: error while loading shared libraries: libvpx.so.1: failed to map segment from shared object: Permission denied )
my PHP
exec('ffmpeg -i…
RussellHarrower
- 145
- 2
- 7