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.

0
votes
2answers
34 views

How do I use command line arguments passed to a shell script that uses xargs?

I have a script that will iterate a set of git checkouts and run a git command in each directory. I now want to be able to pass a parameter to the shell script from the command line and have that ...
0
votes
0answers
10 views

How to execute a script on several nodes using Slurm?

I have a R code that I want to execute on several nodes using Slurm, with each iteration of my paramater which goes on a node. This is my Slurm code : #!/bin/bash #SBATCH -o job-%A_task.out #SBATCH -...
3
votes
2answers
72 views

How to include custom command options in a bash script with $1 and $2?

I have a script myscript.sh #!/bin/sh echo $1 $2 which is used something like ... ./myscript.sh foo bar which gives me an output of ... foo bar but how can i make this script include custom ...
2
votes
4answers
97 views

Correctly quote array that is being passed indirectly via another command

I need to pass an array of filenames to a command, preserving proper quoting. So far, so good. Unfortunately the command is actually a sub-command that is, in turn, invoked by another command. ...
-1
votes
1answer
61 views

Bash script, error “Arg list too long”

I need to run a bash script in a .lua file: os.execute ("/path/to/file.sh") file.sh: #!/bin/bash route add 149.36.98.78 reject The permissions for file.sh is [-rwxr-x---] root www-data I'm ...
1
vote
2answers
38 views

For loop printing echo command only once

In this small for loop I created, I need the loop to print this message only once for all arguments. for arg in $@ do echo "There are $(grep "$arg" cis132Students|wc -l) classmates in this ...
2
votes
2answers
86 views

How do I delete files except some specific files passed as parameters?

The task is to write a shell script with n+1 arguments where the first one is the directory and the rest is the specified files and will delete all but specified files. E.g. calling rmexcept . '*....
6
votes
3answers
458 views

How can I list files in reverse time order by a command and pass them as arguments to another command?

I have a program which takes in some files as arguments in one command line. I would like to invoke it with all the files in a directory listed in reverse time order. For example: I have following ...
11
votes
4answers
2k views

Why doesn't using multiple commands with a || or && conditional work?

This works on a shell (bash, dash) prompt: [ -z "" ] && echo A || echo B A However, I am trying to write a POSIX shell script, it starts like this: #!/bin/sh [ "${#}" -eq 1 ] || echo "...
2
votes
2answers
54 views

What is the Position_args in man page

I just Joined Linux and I trying to explore commands with the available resources (mainly man pages) It's easy to understand what are the option args(content in usage and options) in a command ...
1
vote
3answers
40 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
547 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
29 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
53 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
199 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
27 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
75 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
61 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
131 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
824 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
43 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
582 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
614 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
379 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
275 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
90 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
212 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
612 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
95 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
190 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
432 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
63 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
743 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
51 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
453 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
164 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
144 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
955 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
46 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
59 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
231 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
368 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
563 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
209 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
445 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
223 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
102 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
60 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
172 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, ...