Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [arguments]

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

1
vote
3answers
36 views

Script with more than one flag

I am trying to create a script that lowercases/uppercases files or directories. modify [-r] [-l|-u] <dir/file names...> I am currently using getopts to check for flags. However, I can't run ...
1
vote
1answer
86 views

Passing arguments from one script to another

Let's say I am in a Bash script and am sourcing a file. How do I pass variables to another script after I source the file like this. sed -i 's/ = /=/' $file source $file Let's say file contains ...
0
votes
1answer
20 views

How to pass list of arguments into a function

I want to pass arguments from a loop into a function func. For simplicity let's say we are working with the loop for x in {1..5} do for y in {a..c} do echo $x$y done done I'm just ...
1
vote
1answer
18 views

Can a subshell fetch an argument within the parent shell scope?

I want to run different versions of a utility onto the same data like so: current_dir$ (cd my_utility_version_dir && exec ./my_util my_data_file) Is there a way for my_util to look for ...
0
votes
2answers
38 views

How to split a string argument in a bash over multiple lines without adding space

I'm running the following command: some_command --flag "foo\ bar\ quux" arg2 This causes the string to be passed as foo\tbar\tquux. I'm looking for a way to have this argument passed ...
3
votes
1answer
38 views

How to execute local script by passing arguments on remote via ssh as a different user?

I am trying to execute a local script on remote server via ssh using keytab authentication. I am able to connect to remote via ssh as sachin(user who gets the ticket) and then I am spawning a bash ...
1
vote
1answer
26 views

Stop a program from reading argument

I ran into an issue where I am using a wrapper around a compiler to do static code analysis. The command looks like: sourceanalyzer -b Program clang -E File The -E argument is for the clang ...
1
vote
3answers
58 views

DOS command to Bash command conversion

I need to make Bash take DOS commands in with arguments and then convert the main command to a Bash command and still use the arguments if there are any arguments. The part I am lost on is how to ...
0
votes
2answers
41 views

What does the -l argument mean in tcsh?

I'm running a tcsh shell. I have questions about the -l option in set -l. When I look at man for the set command, I don't see the -l argument. When using tcsh shell, what does the -l argument mean? ...
1
vote
3answers
120 views

Why is it uncommon for stdin inputs to have option-like inputs, while common for command line arguments?

POSIX and GNU have their syntax styles for options. For all the commands that I have seen, they accept option-like inputs as command line arguments. Is it uncommon for a program to accept option-...
5
votes
1answer
798 views

What's going on with this dash '-' thing?

I was trying to export the Python environment requirements and this is what I intended to do: conda list -e > requirements.txt However I mistakenly typed this instead: conda list -e -> ...
-1
votes
1answer
40 views

Shell Function: Sequence of Pipelines as Argument

I have a shell function (in .bashrc) which creates a temp file, executes the arguments (including all sequence of pipelines), redirects it to a temp file and then open it in VS Code. I invoke the ...
4
votes
3answers
300 views

Passing generated empty strings as command line arguments

I do the following: $ ./input "" Output: argc 2 argv[1][0] 0 But if I want to pass (several) empty quotes in program based manner: $ python -c 'print "\"\""' "" ./input $(python -c 'print "\"\""'...
10
votes
3answers
606 views

How can I generate arguments to another command via command substitution

Following on from: unexpected behaviour in shell command substitution I have a command which can take a huge list of arguments, some of which can legitimately contain spaces (and probably other ...
6
votes
2answers
377 views

How to have a script work with “$@” or a default list of parameters while not breaking paths with whitespace?

I want a script that will run another utility over some default paths if no parameters are passed to it; ideally I want this safe for paths that contain spaces. So far I have script.sh: #!/bin/sh ...
0
votes
1answer
162 views

Understanding the combination of ufw --force enable

I rent a remote machine with Debian/Ubuntu and desire to filter all ports I don't use through iptables via ufw. The only ports I allow (both with TCP and UPD) are 22,25,80,443. If I understand man ...
0
votes
1answer
47 views

Require command line argument for script to run [closed]

I'm trying to require a script to only run if the command line argument provided is a specific text file called dailyUserProcs.20181203 in the same directory as the script. I am also running Putty. ...
2
votes
3answers
186 views

'rename' with expression|replacement with a leading '-' (hyphen|minus)

I have many files like xyz_123_foo.ext for which I would like to add -bar to the filenames at the end to result in xyz_123_foo-bar.ext. I tried: rename . -bar. xyz_* which resulted in: rename: ...
5
votes
1answer
565 views

How to distinguish between a positional parameter and an option?

Both a positional parameter ($1, $2, and so forth) and an option (and/or argument) are both written directly after a command, so what is the definition or phrasing to explain how to distinct them? In ...
0
votes
1answer
58 views

Does Konsole permit launching a terminal with a custom font-size on the command-line?

If I want to launch a Konsole can I do so with a font-size of 30px rather than the default?
0
votes
1answer
95 views

Where can I configure Chromium's default command line arguments?

I've seen lots of places people have suggested to store command line arguments, ~/.config/google-chrome-flags.conf ~/.config/chromium-flags.conf /etc/default, My version of chromium doesn't seem to ...
0
votes
3answers
278 views

Read arguments separated by newline

I have a script and I receive data from stdin as an argument separated by newlines say I have string1,string2 string3,string4 And I want to take sperately string1,string2 and string3,string4. But I ...
1
vote
1answer
57 views

How to make my bash function known to external program

I have bash functions foo and bar in my ~/.bashrc. Function foo calls an external command ext_command that itself takes as one of its arguments another command. I want to pass bar as that command, i....
-3
votes
2answers
535 views

Calling sh with script on stdin and passing command line arguments

This works of course. I can run ./test1.sh cats and the argument cats is passed correctly to ls. $ cat test1.sh #!/bin/sh ls -l $1 Can you tell me how do I make this second example — the same ...
0
votes
2answers
49 views

Are `-name` and `-exec` options or non-option arguments of `find`?

Are -name and -exec options or non-option arguments of find? They look like short options, and they are called find expressions, if I am not mistaken. For example, find . -name "*.txt" -exec echo {} ...
4
votes
2answers
400 views

find -exec {} + argument list limit

I know that when the maximum argument list size is reached, xargs keeps creating new lists until all of the files are included; but does find -exec <command> {} + do the same thing or will it ...
2
votes
1answer
163 views

Does the system-wide limit on argument count apply in shell functions?

The other question asks about the limit on building up commands by find's -exec ... {} +. Here I'd like to know how those limits compare to shells' inner limits. Do they mimic system limits or are ...
1
vote
2answers
132 views

How does the find command know how many arguments to feed with “-exec … {} +”?

In a command like this: find /data ! -type d -exec rm -f {} + the + is for batch execution of rm -f. find should batch as many arguments as possible. But how does it know the limit?
1
vote
4answers
717 views

Argument list too long error with makefile

In a makefile, I have @echo "$(IGNORE_DIRS) $(CLEAN_FILES) $(CLEAN_DIRS) $(REALCLEAN_FILES)" | tr ' ' '\n' >> $@ The problem is that $(CLEAN_FILES) is quite large, so when I run make, I get ...
1
vote
1answer
42 views

Partially use the -y argument when installing things in Debian in one line

I have a long apt-get install sequence and for most software packages I need the -y argument. I could do the following in two lines: apt-get upgrade unattended-upgrades sshguard curl wget git ...
1
vote
2answers
57 views

How can I provide an array as a file argument to a script, so that each element is like a line in a file?

Suppose a bash script expects an argument to be a file. But we have a bash array, and would like to provide the array in some way as an argument to the script, as if there were a file whose lines are ...
4
votes
1answer
189 views

First argument passed to wrapper script is ignored

So I've got the following script: #!/bin/bash echo '-------------------------' echo $0 echo $1 echo $@ echo '-------------------------' exec su -- someuser -c "/tmp/elasticsearch-6.4.2/bin/...
3
votes
1answer
224 views

does bash `shift` command change argument count `$#`

When I use the bash shift command, does that change the argument count in $#? Note from author: When I had this question I did not find it (yet) on this community. Therefore I simply tried it and ...
0
votes
2answers
339 views

How to pass multiple parameters to su <USER> -c “command”

I want to execute composer as non root user. So I renamed main composer executable file to composer-call and then create another executable file called composer. #composer.sh su nginx -c "composer-...
0
votes
0answers
137 views

xargs argument in the middle of command [duplicate]

Why is this command not working? echo 'foo bar' | xargs -I % -L 1 echo yeah % yeah It produces the following output: yeah % yeah foo yeah % yeah bar While I expected the following output: yeah ...
0
votes
1answer
366 views

How to pass argv arguments to a C program using a file or python script in linux?

I used to be able to pass input to C program by first writing a python script and using pipe to send it to the C program as an input or write the output of python script to a file and just doing r &...
0
votes
1answer
117 views

How to detach-sign a file with a specific private key? || Why this fails?

I have a .tar.xz file which I would like to detach-sign using my gpg private key. The problem is, I have multiple of private keys imported to my keyring and need to choose, which one to use. ...
0
votes
3answers
77 views

How to parse arguments with space inside bash function

In bash I am calling function: myFunction "1 2" myFunction() { echo "$1" echo "$2" } this prints me "1 2" and empty row. How I can parse arguments so it will print on one row 1 and ...
2
votes
1answer
52 views

Optional commands for bash script

I have a Bash script that sets various environment variables and runs a program. I want one of those variables to change if I run the command with an argument debug. I know 100% how to do this in Lua ...
2
votes
1answer
106 views

Escape keywords with tmux send

Using tmux to send commands along from one terminal to another, I realize that $ tmux send -t mySession "text" ENTER correctly sends text, but $ tmux send -t mySession "up" ENTER sends text again, ...
1
vote
1answer
96 views

Using the 'a' and 'c' options with the 'dash' command in Unix [closed]

What do the options 'a' and 'c' do when there are used with the command 'dash'? I was unable to understand what that command actually does! I have tried reading the man page but didn't exactly ...
1
vote
4answers
67 views

Pass function argument to defined variable

How can I "inject" a function argument to a defined variable like in this example? mood="i am $1 happy" happy () { echo "$mood" } happy "very" Current output: i am happy Desired output: i ...
1
vote
1answer
50 views

Why does my script not take command arguments?

I have a script: #!/bin/sh function usage() { cat << EOF >&2 Usage: $0 [-h] [-rs <start_num>] [-re <end_num>] -h: help: displays list of options for command $0 -rs<...
2
votes
1answer
185 views

Moving random files using shuf and mv - Argument list too long

I have a directory containing nearly 250K files, which are lots of files, and I want to move x random files to another directory. I searched and I got the solution of using the shuf and mv commands ...
0
votes
1answer
32 views

How to handle options when opening a file passed as argument? [closed]

I am trying to open a file through a script; as long as I pass the file as the first argument there are no problems; for instance: $ cat textExample.txt Much I marvelled this ungainly fowl to hear ...
2
votes
1answer
37 views

Generating quoted command arguments

I'm working with a HTTP API that demands a very particular set of signed headers + JSON body. And I really want to cURL it for debugging and sanity in general. So, I've written a small script that, ...
0
votes
4answers
84 views

Creating n variables in Bash without assigning them one by one?

How do I create n variables in shell scripts without explicitly assigning them? What I mean is something like a loop that creates var1, var2, var3,...,varx, where x is a variable I set earlier, ...
0
votes
1answer
219 views

capture output from java

I am trying to do that : #!/bin/bash set out=$(java -jar -Xmx1024m myJava.jar '$1' '$2' '$3' '$4') echo "$out" python myPython.py $out but with no success... I tried with and without quote (because ...
0
votes
2answers
79 views

Keeping quotes passed to a perl wrapper script

I'm writing a small perl wrapper to setup environment variables, etc., then invoke a command by the same name. ./foo.pl -a one -b two -c "1 2 3" -d done When I output @ARGV, the "" around 1 2 3 have ...
0
votes
2answers
33 views

Bash : Give builded array to function as a list of argument?

I have this issue with borgbackup, but because the reaction is the same, I will use rsync in my example. I want to build an array of arguments by adding a prefix to each, and then give that array to ...