The arguments tag has no wiki summary.
0
votes
1answer
10 views
Pass list of folders to zip command
I have a folder which contains lot's of folders in it.
I don't need to zip all of them and I have a list of folders that need to be zipped in a separate file
The folder list is in the following ...
1
vote
1answer
35 views
How to enclose a quoted variable in quotes
I want to call: ./mjpg_streamer -i "./input_uvc.so -r 320x240" -o "./output_http.so -w ./www" from a C program, running system().
The problem is that I have to enclose shell command in quotes, which ...
7
votes
3answers
648 views
Why do some commands not read from their standard input?
I wonder what when we should use pipeline and when we shouldn't.
Say for instance, to kill certain process which handling pdf files, the following will not work by using pipeline:
ps aux | grep pdf ...
1
vote
1answer
27 views
Kill all queued jobs
I need to kill all the queued and running jobs on my ID. I have tried
at -l | awk '{print $1}'| at -r {}
But I keep getting
{} does not exist
Which leads me to believe that I am parsing ...
0
votes
1answer
53 views
Bash Script : Passing a variable to a bash script that contains quotes, single quotes. etc [closed]
lets assume this is the string:
'a',"b"
it contains both single and double quotes.
how would you pass this to a bash script as a single string ?
this is the bash script:
#!/bin/bash
echo $1
...
2
votes
3answers
56 views
Can I chain pgrep with kill?
I have noticed that | is used to send results of first command to the another. I would like to kill all processes that match a name.
This is what pgrep normally does:
$ pgrep name
5089
5105
And ...
0
votes
1answer
41 views
Pipe output from one command to another command's non standard input [duplicate]
I would like to do something similar to the following:
which someapplciation | cd outputfrompreviouscommand
The command which provides a directory and I would like to be able to make that output my ...
4
votes
3answers
459 views
Passing named arguments to shell scripts
Is there any easy way to pass (receive) named parameters to a shell script?
For example,
my_script -p_out '/some/path' -arg_1 '5'
And inside my_script.sh receive them as:
# I believe this ...
2
votes
2answers
125 views
Arguments, options and dashes
Why do console applications get the arguments started with either:
a) one dash (myapp -arg1 123; ls -al)
b) two dashes (myapp --arg1 123; git push origin master --force)
c) without dashes at all ...
3
votes
1answer
162 views
Solving “mv: Argument list too long”?
I have a folder with more than a million files that needs sorting, but I cant really do anything because mv outputs this message all the time
-bash: /bin/mv: Argument list too long
I'm using this ...
1
vote
2answers
58 views
Default function arguments (manually emitting bash psuedo-signals)
I'm looking for a solution that will automatically allow me to call a function with specific parameters in a certain situation.
Here is the specific scenario:
When an error occurs, I can set up my ...
6
votes
1answer
115 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 ...
0
votes
3answers
389 views
How to write a Java Program / Shell Script combination such that you can call the Java program as a remote command and yet supply a local file?
This is related to How to execute a remote command on a local file?
I wrote a simple Java program that prints the first line of a file -
import java.io.BufferedReader;
import ...
7
votes
3answers
302 views
What defines the maximum size for a command single argument?
I was under the impression that the maximum length of a single argument was not the problem here so much as the total size of the overall argument array plus the size of the environment, which is ...
8
votes
3answers
261 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
32 views
Escaping dash in `dch` call
I'm using dch to modify the changelog for a debian package that is being built using some bash script. The messages for changelog are taken from some data source and are just passed to dch --append.
...
1
vote
2answers
79 views
get arguments passed and put it in an array
is there a way to make the arguments passed become the element of an array?
I want to access those arguments individually through array.
like this:
./script.ksh arg1 arg2 arg3
then it will become ...
1
vote
1answer
116 views
How can I use a loop inside a command?
I'm writing a shell script that contains a command that takes multiple directories as space-separated input arguments (like ls). I would like to fill in those arguments from a variable but don't know ...
1
vote
1answer
203 views
How to pass arguments to 'source' command?
My source command in the CShell goes like this :
source /directory/of/script/script.csh
The script.csh executes and in between, waits for my password to confirm the identity.
I am tired of typing ...
1
vote
1answer
58 views
Bash: show prompts if arguments weren't provided
What is the best way of supporting in the script prompts and arguments at the same time? I want to show prompts if arguments weren't provided.
Is there something better/shorter than this? โฉ
...
4
votes
2answers
401 views
CP: max source files number arguments for copy utility
Consider that there are countless number of files under /src/
cp /src/* /dst/
How many files cp will successfully process?
3
votes
2answers
130 views
Command substitution interpreting spaces within quotes as argument separators
I'd like an alias that additionally appends itself to ~/.bashrc, e.g.
function tailias
{
$(echo "alias $1='${*:2}'" | tee -a ~/.bashrc)
}
I'm using tee to split the command to ~/.bashrc while ...
1
vote
5answers
1k views
Pass the output of previous command to next as an argument
I've a command that outputs data to stdout (command1 -p=aaa -v=bbb -i=4).
The output line can have the following value:
rate (10%) - name: value - 10Kbps
I want to grep that output in order to ...
1
vote
0answers
80 views
Mounting root filesystem while booting through network
I have two systems, let say one is the server and the other is the client.
I want to load kernel image from the server to the client through the network.
I used dhcp (isc-dhcp-server) and tftp ...
1
vote
1answer
86 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 ...
1
vote
1answer
150 views
How to use command line arguments in a shell script
I have a shell script and when invoking it ./test it asks for an input.I 've seen a quicker way just by writing at once ./test myInput ,how is that achievable?
3
votes
3answers
420 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 ...
3
votes
2answers
1k views
Bash globbing and argument passing
I have the following simplified bash script
#!/bin/bash
files=("$@")
if [ "X$files" = "X" ]; then
files=$HOME/print/*.pdf;
fi
for file in "${files[@]}"; do
ls "$file";
done
If I pass ...
2
votes
2answers
1k views
How do I echo just 1 column of output from ls command?
Lets say when I do ls command the output is:
file1 file2 file3 file4
Is it possible to display only a certain column of output, in this case file2? I have tried the following with no success:
echo ...
15
votes
2answers
492 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. ...
1
vote
2answers
102 views
Meaning of the following linux commands
cat "$1" > /tmp/file.$$ 2>/tmp/file0.$$
grep "*" /tmp/file.$$ >/tmp/file0.$$
I understood that in the cat command, if an error occurs, the error will be shown in file0.$$ and if it ...
0
votes
2answers
203 views
Making md5sum understand file names with spaces
I need to use md5sum in Python by using pipe to calculate checksum for a bunch of .mp3 files... is there a command which ignore whitespaces in filenames on the command line of md5sum program?
For ...
3
votes
3answers
263 views
What is a “non-option argument”?
I am trying to understand info who but completly fail at the term »non-option argument«. Can someone please explain this term to me in simple words or an example?
UPDATE: from ' info who' ...
2
votes
5answers
551 views
How to use filename arguments or default to stdin, stdout (brief)
I want to handle filenames as arguments in a bash script in a cleaner, more flexible way, taking 0, 1, or 2 arguments for input and output filenames.
when args = 0, read from stdin, write to stdout
...
1
vote
1answer
61 views
devilspie detect if application was started with a flag
How can I set devilspie to detect if an application was started with the flag --hello-world from terminal?
For example window_name detects the window title. How can transform in devilspie the ...
2
votes
3answers
238 views
Convert newline-delimited list with spaces into arguments
I'm trying to write a script that I can run from the context menu in Caja (a clone of Nautilus). Its purpose is to pass the files that are selected in the file manager to a given program (for example, ...
1
vote
1answer
339 views
--no-desktop and %U what for?
I want to know why is this argument so important when lauching nautilus or pcmanfm. What happens if i don't?
Also, i want to know what is the meaning of %U for:
Exec=pcmanfm %U
9
votes
2answers
1k views
How does ps know to hide passwords?
Witness:
$ ps f
PID TTY STAT TIME COMMAND
31509 pts/3 Ss 0:01 -bash
27266 pts/3 S+ 0:00 \_ mysql -uroot -p
25210 pts/10 Ss+ 0:00 /bin/bash
24444 pts/4 Ss 0:00 ...
3
votes
4answers
135 views
How can I print “-n” with `echo`?
I feel really stupid, yet I can't figure how to print the string "-n" with the over 30 years-old command echo.
I tried these:
Michaels:Scripts$ echo -n
Michaels:Scripts$ echo "-n"
Michaels:Scripts$ ...
3
votes
2answers
205 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 ...
3
votes
1answer
609 views
Is there an easy way to log all commands executed, including command line arguments?
I am trying to find how to log a specific instantiation of rrdtool to see whether the path it is receiving is incorrect.
I know I could wrap the executable in a shell script that would log the ...
2
votes
2answers
114 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 ...
5
votes
2answers
2k views
find + xargs: argument line too long
I have a line like the following:
find /foo/bar -name '*.mp4' -print0 | xargs -i {} -0 mv -t /some/path {}
but I got the following error:
xargs: argument line too long
I am confused. Isn't the ...
3
votes
2answers
809 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
1k 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 ...
2
votes
1answer
360 views
UNIX-, BSD-, GNU-options in Linux's ps command. Where are they from? [closed]
In the manual for the ps command on Ubuntu there is this text:
This version of ps accepts several kinds of options:
1 UNIX options, which may be grouped and must be preceded by a
...
2
votes
2answers
185 views
Pass arguments to function exactly as-is
I have the following function:
bar() { echo $1:$2; }
I am calling this function from another function, foo. foo itself is called as follows:
foo "This is" a test
I want to get the following ...
2
votes
2answers
298 views
shell script options pass through to sub-command
I'm writing a wrapper script for that uses getopts to set various options for mysqldump. It's working well so far.
However one thing I would like to do is be able to add another option in my shell ...
10
votes
4answers
327 views
Is there a way to refer to multiple files in a directory without retyping the whole path? [duplicate]
In a bash shell, when I have to remove multiple files in the same directory, I currently need to do something like this:
rm /some/path/file1 /some/path/file2
Is there a shorter way to write this so ...






