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

learn more… | top users | synonyms

1
vote
1answer
33 views

Possible to reuse first argument of BASH line in the same line?

I do this in BASH echo test "$1" ..expecting to get.. test test ..but I get.. test Is this something possible to do? It would make my life easier since having a list files I could do ...
1
vote
2answers
46 views

Specifying comma-separated command line parameters based on text file lines

I want to run a command like: command argument --parameter=param1,param2,param3 where param1, param2, param3 may be any number of parameters coming from a file params.txt, each on one line. I can ...
1
vote
2answers
32 views

bash: --argument vs -arg [duplicate]

In most scripts (but mainly bash) it's commonplace to see some arguments that are configured like so: bash-4.3:$ command --longer-argument -la Where did this originate from? I'm mainly just curious ...
-1
votes
3answers
42 views

Run su -s with arguments

I run to run a command using the su -s command to start a process. Since I do not want the root user to own the process. I try to do this by issuing the command su -s "$CATALINA_HOME/bin/catalina.sh ...
0
votes
0answers
26 views

Comparing floating number to 0 [duplicate]

My positional parameters: readonly THINKING_TIME=$6 readonly EATING_TIME=$7 Hey, recently I've been working on "Dining philosphers problem" and I encounter some difficulties when I tried to do ...
3
votes
1answer
47 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
63 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" ...
2
votes
1answer
30 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
39 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
68 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
23 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 "$...
0
votes
1answer
67 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
39 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= ...
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
2answers
38 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 ...
0
votes
3answers
99 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, ...
2
votes
2answers
58 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
72 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 ...
0
votes
1answer
29 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 ...
6
votes
5answers
594 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 ...
4
votes
1answer
96 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 ...
0
votes
1answer
32 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
70 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 ...
1
vote
1answer
48 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
1k 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 ...
3
votes
2answers
304 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 -: #####...
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 ...
1
vote
2answers
103 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 http://think-like-a-git.net/sections/about-this-site/who-this-site-...
3
votes
2answers
251 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 /proc/29481/...
0
votes
2answers
123 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
251 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
112 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 � J�)���!���#���)���!�)���!�)���!�)...
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]- ...
0
votes
2answers
234 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 (ftp://ftp.ncbi.nlm.nih.gov/...
3
votes
1answer
119 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 ...
1
vote
1answer
49 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
40 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: /home/alexandre/dropbox....
1
vote
2answers
223 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
68 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? Furthermore,...
0
votes
2answers
69 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
74 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
50 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
85 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 '...
3
votes
2answers
182 views

What's the `name` argument to `sh` for/do?

Taken from FreeBSD's man page on sh (because its the most convenient online, target platform is Debian if it matters): SH(1) FreeBSD General Commands Manual SH(1) NAME sh -- ...
-1
votes
1answer
82 views

script with no arguments should echo a message, but it doesn't [closed]

I'm questioning why my script still does not run the condition when no argument is provided. I think it might be the ordering of my if statements but I'm not sure. Any advice? It doesn't seem to be a ...
1
vote
2answers
57 views

Jump to specific flag in help/man file

Let's say I'm curious about what a specific flag -T means for a command ls? Is there a way to jump straight to that using man ls...? or, and this is a slightly different question because it's not ...