An argument is usually defined as the actual value passed to a function, procedure, or command line program.

learn more… | top users | synonyms

3
votes
1answer
42 views

Shell syntax for redirecting arguments?

If I want to redirect not the stdio but as arguments the output of a program , should I use xargs? For example, I do ls and I want the filenames to be arguments to the next command rather than an ...
0
votes
2answers
47 views

What's the difference between a flag, an option, and an argument? [closed]

Examples: ls -a (I consider -a an option) sudo -u username (-u = option, username = arg) chmod 664 my-dir (664 = option, my-dir = arg) I can't think of an example that might say "this is a flag" ...
7
votes
4answers
31k 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 ...
2
votes
1answer
28 views

Variable with colon, dash in an if-then-else: `if [ “${2:-}” = “Y” ]` [duplicate]

How does "${2:-}" work in an 'if-then-else example' below? Somehow I cannot help but think that being ${2:-} it means the second argument, but I am curious what the colon(:) and dash(-) after the ...
2
votes
1answer
35 views

Passing a git command as an argument

I'm trying to automate some tedious parts of a student job I'm working on. Basically, the goal is to clone a bunch of git repositories (which I already have working), then run the same git checkout ...
0
votes
1answer
55 views

How to use ClamAV to scan the memory

How can I only scan the computer RAM for viruses using the ClamAV command clamscan? I already tried, because I found it on ClamWin forum: clamscan --memory But it seems, that the Linux version ...
1
vote
0answers
20 views

Use a bash array as a place-in argument list (with Midnight Commander)

I'm having a little bit of trouble figuring out how I can use a bash array for an argument list. so far, the below code does not work. The %s below is Midnight Commander specific. F=(%s); for i in ...
26
votes
2answers
3k views

When do I need to specify add_efi_memmap as kernel argument in UEFI/EFI boot?

I am reading some tutorials how to EFI stub (efistub) load the Linux kernel. These instructions often use kernel boot parameter add_efi_memmap. The intended hardware is Intel x64 having 8GB of RAM. My ...
0
votes
1answer
55 views

ZSH, concatenate passed in arguments into a single string

I would like to create a simple bash function to use for my convenience. Following the answer given at: Joining bash arguments into single string with spaces I've been able to mash up this small piece ...
-1
votes
4answers
35 views

How can I address the path/file I just specified again? [duplicate]

Say I'll start writing sudo cp /etc/var/more/evenMORE/fileABC and as the target of the copying, I'd like to define the same folder, except just a different filename (whether it is a new name like ...
0
votes
2answers
36 views

bash script function argument problem [duplicate]

Not sure why this is producing error. This is a test code emulating my real code. I want to write a wrapper for find and want to allow for any argument, so I'm wrapping each arg in single quotes. ...
1
vote
0answers
19 views

Creating command from some of the arguments to a bash script including whitespaces [duplicate]

I have a bash script that takes some arguments and uses some of them to loop over some action while some others (those of the form 'a=b') are passed to that action. Essentially, it looks like args= ...
0
votes
1answer
28 views

Parsing a delimited in ksh as command argument

My system generates a flat file with 7 arguments : Field1,Field2,Field3,Field4,Field5,Field6,Field7 Field1,Field2,Field3,Field4,Field5,Field6,Field7 Field1,Field2,Field3,Field4,Field5,Field6,Field7 ...
1
vote
2answers
31 views

Use file in directory as argument but without the extension

I have a file called "data1.dat", I want to be able to use the file as an argument in my script without the .dat extension: ./myscript.sh data1 instead of ./myscript.sh data1.dat is this ...
0
votes
3answers
87 views

How to stop a user from seeing command line arguments?

We have a CI server application run as the build user. Any command with arguments run by the CI server is visible via ps. Although non-admin users do not have access to load a shell on the CI server, ...
0
votes
2answers
37 views

Creating an argument in unix

This might be a dumb question. But, how do you create an argument in unix. I have to create a shell program that takes in a userid as an argument to see the status of an another user's session. My ...
2
votes
2answers
56 views

Repeating command line argument

I want to start off by distinguishing that Repeating command with different filenames is not what I am asking. My question is, how do you build a single command with a directory of filenames in it, ...
0
votes
1answer
61 views

How can I succesfully call the execv function? [closed]

I am trying to make a program that will copy file1 into file2 the following way: cp -i -p file1 file2 Now I call my executable copy and so by calling copy file1 file2 It will do the same thing ...
6
votes
5answers
560 views

BASH: how to pass a default argument if no arguments after the first were passed

I have a bash script with a case statement in it: case "$1" in bash) docker exec -it $(docker-compose ps -q web) /bin/bash ;; shell) docker exec -it $(docker-compose ...
2
votes
2answers
7k views

What's the difference between STDIN and arguments passed to command?

I could use the either form to execute the cat method: cat file_name cat < file_name The result is the same Then I want to execute man in the format of stdin man < file_name While ...
4
votes
1answer
84 views

How to remove a positional parameter from $@

Basically, I want to "pluck out" the first occurrence of -inf from the parameter list. (The remaining parameters will be passed along to a different command.) The script I have has the following ...
1
vote
1answer
65 views

get first CLI argument after the options in shell scipt

I have a script I class like so gitploy up -t 2.0.0 test_repo. I pull out the "action" up right away, then I need to be able to get the test_repo before I process the options. I don't want to lose ...
0
votes
1answer
31 views

get command line agrument by variable in shell script

I want to get the arg of a command from a var that has the index in it of the arg that I want. Something like this # command in terminal, `foo -r -f value_wanted` index="3" var=$"$index" echo $var ...
1
vote
1answer
47 views

How to prevent bash from transforming arguments?

I am trying to use an argument of the script to find other files. The problem is that when i give the script the argument x.* in the command line, it is transformed into x.sh. Any ideas how i can get ...
12
votes
4answers
966 views

Why doesn't echo called as /bin/sh -c echo foo output anything?

For example, while this works: $ echo foo foo This doesn't: $ /bin/sh -c echo foo Whereas this does: $ /bin/sh -c 'echo foo; echo bar' foo bar Is there an explanation?
0
votes
0answers
21 views

Match all arguments (like $@) except last? [duplicate]

I was only able to find solutions for matching all but $1. Like shift for example. Like: command argument1 argument2 argument3 argument4 I would match argument1, argument2 and argument3 but not ...
0
votes
4answers
11k 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 ...
3
votes
2answers
255 views

Passing paths with spaces as arguments

I am having difficulty in passing some string variables having spaces in them as arguments to a program. For debugging and showing the arguments being passed, I created a demo Python script -: ...
6
votes
5answers
4k 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. ...
1
vote
1answer
38 views

globbing and $# [closed]

Suppose my shell script gets 3 arguments: ./myscript dir1 material dir2 I need $# to report the count of items globbed with dir1/* and not the count of my script's original 3 arguments. Do you ...
28
votes
5answers
30k 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
96 views

How to specify multiple input arguments stored in a file to a command?

I would like to convert several webpages into a pdf file, by: wkhtmltopdf http://think-like-a-git.net/sections/about-this-site.html ...
3
votes
2answers
224 views

Content of /proc/<PID>/cmdline file depends on script shebang?

I have a bash script named test.sh which I start with startproc. In case I use #!/usr/bin/env bash shebang in test.sh, the /proc/<PID>/cmdline file looks following: SERVER:~ # cat ...
0
votes
2answers
110 views

In a folder with many files how to do rm on lots of them [duplicate]

I just experimented a bit in linux and ended up getting very many files in one and the same folder. Now when I try to do rm -f folder/*.png I get -bash: /bin/rm: Argument list too long ...
0
votes
0answers
17 views

Difference between “$@” and “$*” when passing arguments to bash function [duplicate]

I'm having hard time understanding difference between $@ and $* when passing them to functions. Here is example: function a { echo "-$1-" "-$2-" "-$3-"; } function b { a "$@" } function c ...
1
vote
2answers
221 views

How does 'find -exec' pass file names with spaces?

If I have a directory containing some files whose names have spaces, e.g. $ ls -1 dir1 file 1 file 2 file 3 I can successfully copy all of them to another directory like this: $ find dir1 ...
0
votes
1answer
84 views

picocom -b 115200 - Why do you need to specify the baudrate?

I have an intel galileo board and if I try to connect to it from my laptop with: picocom /dev/ttyUSB0 I get just akward characters like: Terminal ready � ...
3
votes
1answer
118 views

How to determine program success when running a sequence of similar tasks?

I am writing a series of CLI tools that share the same parent command, similar to programs like git. program verb OPTIONS One of the action verbs, install, is designed to git clone as many ...
0
votes
2answers
207 views

While loop for bash scripting to read either stdin or arguments

I'm playing around with the accepted answer from this thread: Bash script that reads filenames from a pipe or from command line args? When I use the below script, efetch ...
2
votes
5answers
47 views

What determines how program arguments needs to be separated?

I noticed that kill utility is able to accept arguments separated both by a space character and a newline: $ sleep 120 & sleep 240 & [1] 75341 [2] 75342 $ /bin/kill $(echo "75341 75342") [1]- ...
1
vote
1answer
43 views

Alias gedit to accept an argument

This alias works in UNIX and in Redhat. It does not work in Fedora alias te 'gedit "\!*" &' Usage: te myfile.cpp It opens gedit with myfile.cpp in the edit window and runs in the ...
1
vote
2answers
38 views

pipe as arguments

I'm trying to use the output of a command as arguments: The command: /home/alexandre/dropbox.py exclude add ls | grep -v photos I have to add a list of files, for example: ...
1
vote
2answers
219 views

Call one shell script with another

If I have a program that multiplies the user-supplied value with 10, how do I write another bash script that has arguments passed to it and takes these arguments and collects the output of the other ...
1
vote
2answers
11k views

How to pass argument with spaces to a shell script function? [duplicate]

I'm trying to pass multiple argument to a function, but one of them is consist of two words and I want shell function to deal with it as one arg: args=("$@") function(){ echo ${args[0]} echo ...
6
votes
3answers
4k 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. ...
1
vote
2answers
64 views

What does the `set — $args` line do here, and why does it behave differently between Zsh and Bash?

In the manpage for the version of getopt that comes with Mac OSX, an example is given that uses the construction args=$(getopt optstring $*); set -- $args. What does set -- $args do here? ...
0
votes
2answers
65 views

Passing contents of a file on the command line [duplicate]

I'm trying to figure out how I can send arguments (which are contents in a file) on the command line as parameters to a cpp function. I am NOT trying to send it through stdin. I have a function named ...
1
vote
1answer
63 views

Indirectly expand variables in shell

I need to indirectly reference a variable in the bash shell. I basically want to what you can do in make by writing $($(var)). I have tried using ${$var} which would be the most straight forward ...
3
votes
1answer
49 views

functions arguments

I am having trouble with what should be a simple bash script. I have a bash script that works perfectly: function convert_to () x_max=2038 y_max=1146 x_marg=100 y_marg=30 x_grid=150 y_grid=150 if ...
0
votes
1answer
75 views

Expand parameter in quotes in zsh

(Not sure the title is adequate, at least I tried my best…) I want to pass function arguments to zsh’s emulate to evaluate a command in bash emulation: $ .bash() { emulate bash -c "$*" } $ .bash ...