Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [parameter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
27 views

What do (G) and (S) mean in samba's parameter configuration?

In the official documentation of Samba, the smb.conf(5) page has an "Explanation Of Each Parameter" section. For some parameters, two possible values (either (G) or (S)) are shown at the end ...
Manuel Jordan's user avatar
0 votes
1 answer
41 views

how to configure sudo to allow certain parameter

In particular I want to allow the following command without password: sudo cfgutil --ecid "${Device_ECID}" install-application "${in_File_Name}" With Device_ECID and in_File_Name ...
Martin's user avatar
  • 113
1 vote
1 answer
67 views

Bash parameter substitution with multi line error message

I'm using parameter substitution with an error message, such as ${var1:?'some message'}. I've incorporated a multi-line error message. Presently, it only functions properly when enclosed within single ...
programmer Erfan's user avatar
2 votes
2 answers
151 views

Parameter expansion of variable containing control characters

I'm looking to replace the group separator control character, which is printed by the terminal as "^]" and has got octal code of: 035, with a space. This can simply be done using tr, like so:...
Maikol's user avatar
  • 165
0 votes
4 answers
120 views

How can I use parameter expansion together with command substitution?

I want to create 12 directories named after the months. So I tried using locale to get the month names, piping to tr to separate them with commas, then put braces around and passed to mkdir. But ...
teraspora's user avatar
  • 111
0 votes
1 answer
377 views

Can I configure parameters when launching flatpak apps from the GUI?

One of my Flatpak application stopped working properly, probably after a silent upgrade. I found a fix online that tells me to add a parameter. That fix works. Nonetheless, I like running that app ...
SteeveDroz's user avatar
0 votes
0 answers
83 views

Issue regarding flames game in shell script

I am trying to make a flames game in shell script. I take 2 names and sort names. My code like this: var=$(j=1;for((i=0;i<${#name1Low};i++));do echo "${name1Low:i:j}";done |sort|tr -d '\n'...
utkarsh dubey's user avatar
1 vote
1 answer
312 views

Splitting parameter list

I want to create a bash function that will accept variable number of parameters. There must be at least one parameter. Then I call another program and need to insert fixed values between the first ...
Ivan Onyshchenko's user avatar
4 votes
2 answers
270 views

Is it possible to apply substring expansion to all elements of a zsh array?

Let's say I'd like to remove the first two and last three characters from all elements of an array e.g. results=( QK9H9UtADCgnG AlaLkCADjQ krsxseW8H1VrU 6nBG94ZbCWQ ) I'd like to end up with results=(...
don_crissti's user avatar
  • 83.2k
7 votes
3 answers
631 views

Is it possible to print a command so that the output can be parsed to create the same command?

The question may sound quite complicated, but in fact it is not! Consider: % f() { echo "$@"; } % f a a % f cmd -o"value with space" cmd -ovalue with space % f cmd -ovalue with ...
U. Windl's user avatar
  • 1,483
7 votes
3 answers
648 views

Remove repeating string pattern from variable with POSIX parameter expansion

I wanted to use 2.6.2 Parameter Expansion to remove leading characters from a string, but was surprised to find out that "Remove Largest Prefix Pattern" doesn't automatically repeat the ...
finefoot's user avatar
  • 3,090
3 votes
2 answers
606 views

Bash Parameter Expansion - Get Variables with a Prefix while Escaping Hyphen

EDIT: I realized I was mistaken about a central assumption in this post: The ${!prefix@} syntax isn't able to get function names, but only variables. Therefore, there is no way to get ${!prefix@} to ...
Q Z's user avatar
  • 133
0 votes
1 answer
3k views

Replace $placeholder text in various configuration files with $placeholder parameter

I am at my wits end trying to get sed to do this for me and I feel like an idiot. So I hope someone has a much smarter way to accomplish what seems to be incredibly simple. file.conf: USER: !USER! ...
cmjordan's user avatar
0 votes
1 answer
372 views

Assigning $* in shell script from args array

After iterating thru the shell arguments and filtering out unwanted arguments into an array, I want to assign the array back to $*. For example, in the below script, I want to remove the arguments -f ...
user3118280's user avatar
2 votes
1 answer
242 views

BASH: is it possible to change a prompt of function based on its parameter?

I want to construct a function that will change its user input prompt based on its parameter. my_fucntion takes 1 parameter as db_host after prompting the user for input: function provide_host () { ...
Sollosa's user avatar
  • 1,941
1 vote
1 answer
288 views

libvirt nwfilter, multiple parameters

It's possible to pass multiple parameters to the "filterref" using "parameter" keyword. Like this: <filterref filter='no-ip-spoofing'> <parameter name='IP' value='10.0....
LovingFox's user avatar
0 votes
1 answer
150 views

Bash still cut the last part of the third parameter even if I attempted `$*` and `$@`

I have tried the following questions: Propagate all arguments in a bash shell script How may I echo all but the last parameter in bash? I was running docker-compose that checks Dockerfile. See my ...
Oo'-'s user avatar
  • 243
0 votes
1 answer
259 views

What is the best way to pass a parameter to a running script?

There is a script (on dash) that runs at system startup (as a daemon). The script is run under root. From under a user I create a file with the right parameter, and the script checks once a second if ...
NewLinux's user avatar
  • 147
1 vote
2 answers
331 views

Please explain the behavior of these parameter expansions using IFS?

I'm trying to figure out how to use the ${parameter%word} expansion with $@ and $*. It started by trying to make a script to combine pdfs using ghostscript, but I ran into some weird behavior with ...
mangoduck's user avatar
0 votes
0 answers
39 views

korn script printing garbage for param sent to function in utils file

I have a korn util script that isn't receiving correct parameters. I'm not sure why. I'm new to korn, and searching for the issue online didn't help. I execute the calling script this way from ...
Michele's user avatar
  • 103
0 votes
0 answers
91 views

Why does piping input to a Bash function prevent assignment to a local nameref variable? [duplicate]

Given Bash 5.0.17 and the function function assign_greeting { local -n output_var=$1 output_var=$(cat) } why does echo $GREETING in $ echo Hello | assign_greeting GREETING $ echo $GREETING $ ...
Derek Mahar's user avatar
4 votes
2 answers
1k views

Zsh use an array in a find command

I would like to rsync over a few files, specified with an array, and delete any other file in a directory. The only approach I can think of is to remove other files using find, and rsync over the ...
simonzack's user avatar
  • 723
0 votes
1 answer
1k views

How to retrieve items from an array of arrays?

Hello StackExchange pros! I am working on a zsh project for macOS. I used typeset to create three associative arrays to hold values, and a fourth array to reference the individual arrays. Is it ...
jamesrg71's user avatar
1 vote
1 answer
178 views

Zsh: How to make `${x:?}` return non-zero in case of empty `$x`?

How to make ${x:?} return non-zero in case of empty $x? By default, it exits the shell (subshell in this example) with 0. function sth() { local url="${1:?}" ... } (sth) ; echo $? # ...
HappyFace's user avatar
  • 1,612
1 vote
1 answer
2k views

How to pass variable arguments to expect

I want to pass a variable number of arguments to a expect script: #!/usr/bin/expect set timeout 10 spawn ssh -o "StrictHostKeyChecking no" [lindex $argv 0]@[lindex $argv 2] expect "...
michelemarcon's user avatar
0 votes
0 answers
156 views

The IF statement parameter dimensional x in BASH script [duplicate]

I have found this in an old script but can't tell what is the use of the "x" infront of the ${VARIABLE} and infront of the value "onx" being compared VARIABLE="${VARIABLE:-&...
Technas's user avatar
0 votes
2 answers
1k views

How to get the filename from an array of absolute paths of filenames

I have a shell script that needs to delete the file names from the /tmp directory. The file names must be detected from a list of file names passed to my script. ./deletetmpfiles.sh /var/moht/test1....
Ashar's user avatar
  • 501
1 vote
0 answers
82 views

Bash: Parameter Expansion | Parameter Transformation on List of Assoc.Array Keys

Is this possible(bash v5.0.3)? I'd like to dynamically populate a select list using the keys of an associative array (for further code reuse & script automation). Some keys simply require ...
Joshua Hall's user avatar
0 votes
0 answers
50 views

Shell script getopts weird behaviour args not parsing

I'm trying a simple shell script to get the arguments passed by the user, but cannot seem to find my error. Sometimes it works, but mostly not (weird). helpFunc() { echo "" ...
Omar Omeiri's user avatar
0 votes
0 answers
15 views

Passing a parameter with quotes to a shell script [duplicate]

I have a useful script greplog that does: grep -Eh --color $1 /var/log/apache2/other_vhosts_access.log{.1,} so I can easily search like this: greplog index.php But greplog "POST /test.php" ...
Basj's user avatar
  • 2,549
4 votes
6 answers
2k views

Command parameters & arguments - Correct way of typing?

Which is the correct way - to separate the argument from the parameter with a whitespace, or no? And should you separate arguments or stick them all together? Examples: <command> -D 192.168.0....
Nakkisormi's user avatar
12 votes
3 answers
20k views

How to pass all arguments of a function along to another command?

Hello I have this in my ~/.bash_profile export GOPATH="$HOME/go_projects" export GOBIN="$GOPATH/bin" program(){ $GOBIN/program $1 } so I'm able to do program "-p ...
nooby's user avatar
  • 131
4 votes
1 answer
416 views

Indirect parameter expansion in associative array

Following this answer, I want to apply the approach on my script. The basics of it is: foo="bar" baz="foo" echo "${!baz}" bar I want to provide translated strings, like ...
schrodingerscatcuriosity's user avatar
1 vote
1 answer
620 views

Remove the first parameter in $*

I've got a small "logit" script; #!/bin/bash echo "• $(date +%Y.%m.%d.%H.%M.%S) • " >> "$1" printf "%s" "$*" >> "$1" This way I ...
JoBe's user avatar
  • 397
7 votes
3 answers
696 views

Most robust way to list every basename in a directory, sorted by modification date?

Given a directory containing: note 1.txt, last modified yesterday note 2.txt, last modified the day before yesterday note 3.txt, last modified today What is the best way to fetch the array note 3 ...
seanakabry's user avatar
1 vote
4 answers
3k views

Find xml tag and replace the text inside the tag to a parameter value multiple occurrences

Find a specific xml tag and replace the text inside tags to some parameterized value. Multiple occurrences need to be replaced. Sample file content: <a>abc</a> Current attempt: sed -i &...
user418743's user avatar
0 votes
2 answers
1k views

how can i detect user input is coming from pipe line or with parameters? (as using "if else")

how can i detect user input is coming from pipe line or with parameters? (as using "if else") example: with pipeline $ cat input_file | ./example.sh hello world with parameters $ ./example.sh "...
rojen's user avatar
  • 184
0 votes
1 answer
543 views

How do I delete the lines in a range that contain a given string from a script?

I believe the title is self-explanatory. I have some files given as parameters and the given string is the last parameter of my script. I have tried the two scripts below and do not know how I could ...
M.Ionut's user avatar
  • 21
0 votes
1 answer
615 views

Passing custom parameter from GRUB to the OS

My program, wich is bash scripts, runs in a custom ISO with Debian. I want a GRUB menuentry that passes a parameter from GRUB to the OS, a debugging flag, so I can test the program, and at the same ...
schrodingerscatcuriosity's user avatar
0 votes
1 answer
31 views

Processing parameters with * passed to unix [duplicate]

I am receiving a query via a configuration file in unix, for ex. Config file content will be in the format: Table_name|query ABC|select ABC.A,ABC.B from PQR left join (select * from ABC) on ABC.pk=...
Saket Mankar's user avatar
3 votes
2 answers
10k views

How does the tftpd-hpa --verbosity option work?

I'm trying to set up a TFTP server using tftp-hpa, and according to the manpage I can use the --verbosity option to get more output. Unfortunately I can't find anything that explains what I should ...
Malvineous's user avatar
  • 6,923
0 votes
0 answers
127 views

Shell scripting parameters

I have the following script. I want the inputs to be: -a, -l, -s <number>, -c <keyword>, -d <keyword> -b/-r, -n. However, there's a problem with the number and keyword parameter as ...
user25's user avatar
  • 107
1 vote
1 answer
2k views

Apply multitail's filtering to many files passed via wildcard

multitail has a nice regex-based filtering mechanism that is described in the manpage and online manual. Both sources state that log lines matching a given regex can be excluded from output using the -...
jstarek's user avatar
  • 1,710
5 votes
2 answers
951 views

Customize sysctl parameters by user

I know there's *.conf file in /usr/lib/sysctl.d and/or /etc/sysctl.d folders ready to establish kernel parameters on boot. But they are general; what I want is to customize some of these parameters (...
Osqui's user avatar
  • 178
0 votes
0 answers
107 views

How is it possible to call CwRsync.exe via a Bash Script with variables and arguments?

This is the commandline currently used to call Rsync that's part of Cygwin 64 install. rsync -aqHPR $CygSrcRoot/./$FolA1 $CygSrcRoot/./iMazing.Versions/Versions/$FolA1 $CygDstRoot/$DstCountFol --...
Alex S's user avatar
  • 189
0 votes
1 answer
2k views

Why arguments which passed to .sh file are missing after sudo su?

I need to run .sh file on my server from my local machine. I could do it using below command. ssh -p my_port_no -i path_to_key user@ip_address "bash -s" < testOnServer.sh Now I need to pass some ...
Sudarshana Dayananda's user avatar
2 votes
1 answer
478 views

Parsing an array as one of many keyword parameter in a bash script

I have a bash script (script.sh) that takes in many parameters in the format --keyword value. It is read in when the script is invoked with the following lines: # Get our arguments using flags, while ...
nao's user avatar
  • 153
6 votes
1 answer
505 views

What is the historical reason for using curly braces {} as placeholder in find -exec

Everyone knows find . -exec foo {} \; and at some point stopped thinking about it. But recently I came back to the question that arose when I first learned it: Why would anyone choose {} as the ...
Philippos's user avatar
  • 13.5k
2 votes
2 answers
8k views

Check mandatory argument of parameters

I have script with several parameters that have required argument: while [ "$1" != "" ]; do case $1 in -f | --first ) shift first=$1 ...
mkczyk's user avatar
  • 133
3 votes
1 answer
290 views

How to deal with optional input in shell script?

My assignment task is to print n longest lines from text files. The output is n longest lines with line number and in the same order as in the original file. For example, in the original file: ...
amV's user avatar
  • 75

1
2 3 4 5