The arguments tag has no wiki summary.
1
vote
2answers
39 views
Pass arguments to a command run by another user
I have a bash script that is supposed to take some arguments and then run in a different user: test.sh
#!/bin/bash
sudo su user2 <<'EOF'
echo $1
EOF
However it prints blank:
$ ./test.sh ...
2
votes
2answers
87 views
bash how to remove options from parameters after processing
I remember having seen somewhere a bash script using case and shift to walk through the list of positional parameters, parse flags and options with arguments when it encounters them, and removes them ...
2
votes
4answers
45 views
Modify bash arguments if only one argument is set
I created a script with the standard getopt magic, so you can call the script with
batman-connect -c ffki
How can I add an option to call this script with only one option without dash?
...
7
votes
2answers
242 views
Bash string concatenation used to build parameter list
Given this piece of bash:
PARMS='-rvu'
PARMS+=" --delete --exclude='.git'"
echo $PARMS
rsync ${PARMS} . ${TARGET}
The echo shows the PARMS string as expected, no error is displayed, but rsync ...
2
votes
1answer
29 views
How to get clicked-on filename as argument of shell script triggered by this mouse-click
If, in Ubuntu's Nautilus, I click a midi-file, a window opens to specify an application for processing the file. Another option is a "user generated command" (UGC). (Let me choose Ubuntu, Nautilus, ...
4
votes
3answers
102 views
Passing arguments from one command into the next
I'm trying to write a script to unify two separate commands I run by hand into a single bash script I can then cron.
The first command is a simple find on files with a certain name and size
find ...
3
votes
0answers
104 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
2answers
69 views
Shell script to work on files in some directory
I am a noob in Linux hence this might come as a silly question.
I have a Windows system, so I downloaded cygwin to help me execute Linux/unix commands. I need to execute a shell script on a bunch of ...
5
votes
2answers
258 views
How do you get fgrep to find the literal “--help”?
fgrep --help | fgrep "--help"
returns just the whole fgrep --help, how do I return just the lines that have the literal "--help" in them?
The quotes don't do anything, nor does \-\-help.
3
votes
1answer
45 views
scp to an alias
To transfer a folder from my local host to a remote host, I normally do:
$ scp -r myFolder user@host:destFolder/
Trying to make this easier, I aliased the remote host destination:
$ alias ...
0
votes
1answer
72 views
Mandatory argument for script to run java program
My script is called: report_startDate
It has the following line:
$JRE_ROOT/bin/java -cp /home/me/report/config/:/home/me/report/jar/reporting-1.0-SNAPSHOT.jar com.me.project.report.Main $1
$1 ...
19
votes
1answer
251 views
When and how was the double-dash (--) introduced as an end of options delimiter in Unix/Linux?
I don't think the shell/utilities in historical Unix nor in something as "recent" as 4.4BSD supported using a double-dash(or two consecutive hyphens) as an end of options delimiter. With FreeBSD, you ...
32
votes
7answers
3k views
Is `-` used only with cd?
cd - can switch between current dir and previous dir.
It seems that I have seen - used as arguments to other commands before, though I don't remember if - means the same as with cd.
I found that - ...
0
votes
1answer
37 views
Must pass urls in quotes
I'm trying pass a URL to mpv for it to play it as a network stream.
This can be done in bash with the following syntax:
$ mpv http://myvideosite.com
However, zsh wants to evaluate the URL as ...
2
votes
2answers
139 views
Pass argument to script, then redirect script as input to bsub
I am currently working with the bsub job submission system from Platform LSF. I need to submit job scripts, but I am running into a problem with passing arguments to the job script.
What I need is as ...
4
votes
2answers
156 views
Add arguments to bash -c
Let say that I want to run a command through bash like this:
/bin/bash -c "ls -l"
According to bash man page, I could also run it like this:
# don't process arguments after this one
...
0
votes
1answer
50 views
Pass list of folders to zip command
I have a folder which contains lot's of folders in it.
I don't need to zip all of them and I have a list of folders that need to be zipped in a separate file
The folder list is in the following ...
1
vote
1answer
52 views
How to enclose a quoted variable in quotes
I want to call: ./mjpg_streamer -i "./input_uvc.so -r 320x240" -o "./output_http.so -w ./www" from a C program, running system().
The problem is that I have to enclose shell command in quotes, which ...
7
votes
3answers
779 views
Why do some commands not read from their standard input?
I wonder what when we should use pipeline and when we shouldn't.
Say for instance, to kill certain process which handling pdf files, the following will not work by using pipeline:
ps aux | grep pdf ...
1
vote
1answer
51 views
Kill all queued jobs
I need to kill all the queued and running jobs on my ID. I have tried
at -l | awk '{print $1}'| at -r {}
But I keep getting
{} does not exist
Which leads me to believe that I am parsing ...
0
votes
1answer
171 views
Bash Script : Passing a variable to a bash script that contains quotes, single quotes. etc [closed]
lets assume this is the string:
'a',"b"
it contains both single and double quotes.
how would you pass this to a bash script as a single string ?
this is the bash script:
#!/bin/bash
echo $1
...
2
votes
3answers
103 views
Can I chain pgrep with kill?
I have noticed that | is used to send results of first command to the another. I would like to kill all processes that match a name.
This is what pgrep normally does:
$ pgrep name
5089
5105
And ...
0
votes
1answer
153 views
Pipe output from one command to another command's non standard input [duplicate]
I would like to do something similar to the following:
which someapplciation | cd outputfrompreviouscommand
The command which provides a directory and I would like to be able to make that output my ...
6
votes
3answers
5k views
Passing named arguments to shell scripts
Is there any easy way to pass (receive) named parameters to a shell script?
For example,
my_script -p_out '/some/path' -arg_1 '5'
And inside my_script.sh receive them as:
# I believe this ...
2
votes
2answers
149 views
Arguments, options and dashes
Why do console applications get the arguments started with either:
a) one dash (myapp -arg1 123; ls -al)
b) two dashes (myapp --arg1 123; git push origin master --force)
c) without dashes at all ...
3
votes
2answers
2k 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
79 views
Default function arguments (manually emitting bash psuedo-signals)
I'm looking for a solution that will automatically allow me to call a function with specific parameters in a certain situation.
Here is the specific scenario:
When an error occurs, I can set up my ...
6
votes
1answer
136 views
How to specify additional parameters for GNU sort's --compress-program option?
sort --compress-program=/bin/gzip works fine, but how can I pass options down to the compression programm (e.g. --best or --fast)?
sort --compress-program=/bin/gzip\ --best failes with the error ...
0
votes
3answers
3k 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 ...
7
votes
3answers
530 views
What defines the maximum size for a command single argument?
I was under the impression that the maximum length of a single argument was not the problem here so much as the total size of the overall argument array plus the size of the environment, which is ...
8
votes
3answers
344 views
How to execute a command repeatedly with different arguments?
I'm on Ubuntu. I copied some arguments (separated by newline) and I can use xsel to print them out like this
$ xsel
arg1
arg2
arg3
arg4
...
Now, I want to use each of these arguments for another ...
1
vote
1answer
34 views
Escaping dash in `dch` call
I'm using dch to modify the changelog for a debian package that is being built using some bash script. The messages for changelog are taken from some data source and are just passed to dch --append.
...
1
vote
2answers
231 views
get arguments passed and put it in an array
is there a way to make the arguments passed become the element of an array?
I want to access those arguments individually through array.
like this:
./script.ksh arg1 arg2 arg3
then it will become ...
1
vote
1answer
132 views
How can I use a loop inside a command?
I'm writing a shell script that contains a command that takes multiple directories as space-separated input arguments (like ls). I would like to fill in those arguments from a variable but don't know ...
1
vote
1answer
435 views
How to pass arguments to 'source' command?
My source command in the CShell goes like this :
source /directory/of/script/script.csh
The script.csh executes and in between, waits for my password to confirm the identity.
I am tired of typing ...
1
vote
1answer
69 views
Bash: show prompts if arguments weren't provided
What is the best way of supporting in the script prompts and arguments at the same time? I want to show prompts if arguments weren't provided.
Is there something better/shorter than this? ⇩
...
4
votes
2answers
1k views
CP: max source files number arguments for copy utility
Consider that there are countless number of files under /src/
cp /src/* /dst/
How many files cp will successfully process?
3
votes
2answers
176 views
Command substitution interpreting spaces within quotes as argument separators
I'd like an alias that additionally appends itself to ~/.bashrc, e.g.
function tailias
{
$(echo "alias $1='${*:2}'" | tee -a ~/.bashrc)
}
I'm using tee to split the command to ~/.bashrc while ...
1
vote
5answers
4k views
Pass the output of previous command to next as an argument
I've a command that outputs data to stdout (command1 -p=aaa -v=bbb -i=4).
The output line can have the following value:
rate (10%) - name: value - 10Kbps
I want to grep that output in order to ...
1
vote
0answers
115 views
Mounting root filesystem while booting through network
I have two systems, let say one is the server and the other is the client.
I want to load kernel image from the server to the client through the network.
I used dhcp (isc-dhcp-server) and tftp ...
1
vote
1answer
113 views
Using sed output in another script or command
How can I use the output of sed in another script?
For example (this doesn't work):
sed -n "$COUNTER",1p /domains.csv | wget
or
sed -n "$COUNTER",1p /domains.csv > /myScript.sh
As far as I ...
1
vote
1answer
377 views
How to use command line arguments in a shell script
I have a shell script and when invoking it ./test it asks for an input.I 've seen a quicker way just by writing at once ./test myInput ,how is that achievable?
3
votes
3answers
464 views
Correctly parse arguments in script behaving like a shell called through SSH
I have a server with a very limited used whom I want to be able to run two very specific (and custom) instructions through SSH. In order to do that, I have set the shell for that limited user to be a ...
3
votes
2answers
2k views
Bash globbing and argument passing
I have the following simplified bash script
#!/bin/bash
files=("$@")
if [ "X$files" = "X" ]; then
files=$HOME/print/*.pdf;
fi
for file in "${files[@]}"; do
ls "$file";
done
If I pass ...
2
votes
2answers
3k 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 ...
15
votes
2answers
522 views
How can I stream data to a program that expects to read data from a file that is given as a argument?
I have a huge gzipped file and I want a program (4s-import in this case) to read it. It takes a lot of time to first unzip the file and then call the program with the path to the file as an argument. ...
1
vote
2answers
107 views
Meaning of the following linux commands
cat "$1" > /tmp/file.$$ 2>/tmp/file0.$$
grep "*" /tmp/file.$$ >/tmp/file0.$$
I understood that in the cat command, if an error occurs, the error will be shown in file0.$$ and if it ...
0
votes
2answers
246 views
Making md5sum understand file names with spaces
I need to use md5sum in Python by using pipe to calculate checksum for a bunch of .mp3 files... is there a command which ignore whitespaces in filenames on the command line of md5sum program?
For ...
3
votes
3answers
355 views
What is a “non-option argument”?
I am trying to understand info who but completly fail at the term »non-option argument«. Can someone please explain this term to me in simple words or an example?
UPDATE: from ' info who' ...
3
votes
5answers
946 views
How to use filename arguments or default to stdin, stdout (brief)
I want to handle filenames as arguments in a bash script in a cleaner, more flexible way, taking 0, 1, or 2 arguments for input and output filenames.
when args = 0, read from stdin, write to stdout
...