1

I'm a basic user hoping to advance to an intermediate level. Ok, I've a file XAMPP(manager-linux-x64.run) which when i do a

sudo ./manager-linux-x64.run

It works. So, I was trying to go pro by doing this from its directory

ls | grep manager-linux-x64.run | sudo xargs ./

it doesnt work.it throws this error

xargs: ./: Permission denied

The file output of manager-linux-x64.run is

manager-linux-x64.run: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, stripped

What I am essentially trying to do is get a list of files in the directory , grep the executable, pipe the output and execute it using ./manager-linux-x64.run since (sh,bash doesn't work on the .run file).

Moreover, is there any other command that can run a .run itself?

Zanna
  • 72,312
Emma
  • 21

1 Answers1

3

The answer is a subshell. Try this:

realpath $(ls) | grep .run$ | xargs sh -c

Or:

ls -d ./* | grep .run$ | xargs sh -c

Those will work, but it might be better to use find if what you are trying to do is execute a file whenever it fulfills certain conditions.

find $PWD -maxdepth 1 -type f -name "*.run" -exec {} \;


Notes:

The file's executable permission must be set. Change with chmod if needed.

A warning: the previous one-liners will try to execute anything they match. Read about dot slash:

"...A user could eliminate the need to precede commands by a dot slash (...) However, this is generally not advisable on safety and security grounds..."

Samuel
  • 1,025