6
votes
1answer
86 views

How to specify additional parameters for GNU sort's --compress-program option?

sort --compress-program=/bin/gzip works fine, but how can I pass options down to the compression programm (e.g. --best or --fast)? sort --compress-program=/bin/gzip\ --best failes with the error ...
8
votes
3answers
201 views

How to execute a command repeatedly with different arguments?

I'm on Ubuntu. I copied some arguments (separated by newline) and I can use xsel to print them out like this $ xsel arg1 arg2 arg3 arg4 ... Now, I want to use each of these arguments for another ...
1
vote
1answer
59 views

Using sed output in another script or command

How can I use the output of sed in another script? For example (this doesn't work): sed -n "$COUNTER",1p /domains.csv | wget or sed -n "$COUNTER",1p /domains.csv > /myScript.sh As far as I ...
3
votes
3answers
321 views

Correctly parse arguments in script behaving like a shell called through SSH

I have a server with a very limited used whom I want to be able to run two very specific (and custom) instructions through SSH. In order to do that, I have set the shell for that limited user to be a ...
15
votes
2answers
454 views

How can I stream data to a program that expects to read data from a file that is given as a argument?

I have a huge gzipped file and I want a program (4s-import in this case) to read it. It takes a lot of time to first unzip the file and then call the program with the path to the file as an argument. ...
3
votes
2answers
156 views

Why do I need the double dash before argument passed to sh by xargs -I for it to work properly?

Sorry for the mouthful title. Here is the command in question find . -name "*.txt" | xargs -Ifile sh -c 'echo $(basename $1) ' -- file So without the double dash the file is not passed to sh and ...
8
votes
5answers
2k views

cp with a single argument containing wildcards [duplicate]

If I have the following 2 files and 1 folder: someuser@computer:~/Desktop/test$ ls -l total 340 -rw-r--r-- 1 someuser someuser 45082 ago 5 09:56 file1.pdf -rw-r--r-- 1 someuser someuser 291836 ago ...
2
votes
2answers
105 views

Is it possible to create a “file” that can be used by any process without actually saving the file on disk?

Suppose I do a grep that gives me a lot of results. I want to use the output of grep and pass it to a command that takes a filename as it's first argument. For example - myCommand filename.txt I ...
2
votes
2answers
550 views

How to prevent command injection through command options?

I have an wrapper application where I need to let the user specify custom options to pass to a simulator. However, I want to make sure the user doesn't inject other commands through the user options. ...
3
votes
2answers
698 views

how to loop through arguments in a bash script

I would like to write a bash script with unknown amount of arguments. How can I walk through these arguments and do something with them? A wrong attempt would look like this: #!/bin/bash for i in ...
4
votes
2answers
781 views

How to pass arguments to bash shell script when executing that command with at?

I have a shell script that accepts an argument and uses that in the script. So to run the script I type /path/to/script argument The problem is when trying to setup that file to run using the at ...
-1
votes
1answer
94 views

Why do many CLI apps take a single “--” argument? [duplicate]

Possible Duplicate: What does “--” (double-dash) mean? There are many command line tools that take a single "--" argument. For example: gem install mysql -- ...
1
vote
1answer
92 views

Redirection doesn't show up as an argument to a sourced script

My problem is that I can't print to the screen when I write a bash script . myBashScript.sh < text.txt In myBashScript.sh I just print out echo $2 But instead of printing "text.txt", it ...