The tag has no wiki summary.

learn more… | top users | synonyms

6
votes
1answer
89 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 ...
1
vote
3answers
92 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
169 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
203 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
20 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
35 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
94 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
77 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
42 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
141 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
92 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
141 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
54 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
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 ...
1
vote
1answer
82 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
326 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
533 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
478 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
455 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
92 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
162 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
187 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
337 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
53 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
188 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
245 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
806 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
120 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
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 ...
3
votes
1answer
322 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
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 ...
4
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
563 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
710 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
322 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
109 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 ...
1
vote
1answer
230 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
304 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 ...
-1
votes
1answer
150 views

Delimiters of program arguments?

What is the syntax to delimit the arguments of a C program. For example, if I type : ./myprogram 1 2 3 | grep result The | grep result will be interpreted as arguments (and passed as argv). So how ...
2
votes
3answers
782 views

Passing multiple directories to the -prune option in find

I am using find to locate and delete backup files but wish to exclude certain directories from the search. The backup filenames could terminate in .bck, bak, ~, or backup. The Minimal Working Example ...
5
votes
2answers
262 views

Bash : command line with optional arguments

I'm running this kind of code: #!/usr/bin/env bash set -u exclude1='--exclude=/path/*' exclude2='--exclude=/path with spaces/*' exclude3='' # any 'exclude' can be empty tar -czf backup.tgz ...
1
vote
2answers
46 views

Key letters? Option letters? What are these things?

Some GNU and GNU-like tools seem to accept options in a combined manner, e.g. foo -hgcf instead of foo -h -g -c -f. An example is tar, as in tar cXbf keepout 20 archive.shar *.txt instead of tar -c ...
1
vote
1answer
88 views

Why is $* not working as expected?

I'm trying to use $* in a function to expand to all commandline arguments in a function, but it's giving me bizarre behavior: $ function repeat() { echo "$*" } $ repeat puts hello # this gives me ...
3
votes
1answer
64 views

How to put an argument vector with an argument containing spaces in a bash variable

How can I store an argument vector with an argument containing spaces in a bash variable? For example, I want 2.sh to print b c 1.sh #!/bin/bash ARGV='a "b c"' ./2.sh $ARGV 2.sh #!/bin/bash ...
1
vote
2answers
1k views

Pattern matching from the input arguments

we're trying to enhance the scripts. Users will pass some arguments and part of the arguments will have 5.0.3 For an example the input argument would be like Jboss5.0.3GA. Since it ( Jboss5.0.3GA ) ...
1
vote
2answers
1k views

Bash script that reads filenames from a pipe or from command line args?

I want my script to read a bunch of filenames (which may have spaces) given either as a glob or from STDIN and do stuff with them. I've been able to read either way separately, but not combine them. ...
2
votes
2answers
1k views

How do I pass the contents of a file as a command line parameter

I am storing a file path in a file and need to pass the contents of that file as an argument to a shell script, specifically Maven, something like so: mvn -Dvar_name=(contents of file) Would this ...
2
votes
2answers
295 views

Bash: passing braces as arguments to bash function

I love using the following pattern for searching in files: grep --color=auto -iRnHr --include={*.js,*.html,} --exclude-dir={release,dev,} "span" . I'd like, however, to have this one wrapped into a ...
4
votes
2answers
782 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 ...