The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
1answer
15 views

How do I make an alias to substitute single word in a piped command? [duplicate]

I use aliases a lot but right now only for use cases like alias i='sudo apt-get install -y'. I often would like to add an alias in the following form: alias cmd='echo [something] >> ...
4
votes
2answers
42 views

Unzip source arguments

To copy a bunch of zip files from one location to another: $ cp *.zip destination/ To unzip a bunch of zip files to a directory: $ unzip \*.zip -d destination/ man unzip says: The backslash ...
0
votes
2answers
46 views

Why doesn't this pipe command work at this special bash script?

That script test.sh doesn't work after used pipe command. The result shows nothing. Why? #!/bin/bash fun=$( echo $1 ) echo "$fun" commands are as follows, $ echo 1 | ./test.sh
0
votes
2answers
44 views

Can't use argument in bash date calculation script

The following bash script won't work. I need to calculate the date depending on the number of days since 14th Oct 1582, where the argument will be the number of days. d="$1" date -d '14 Oct 1582 + ...
6
votes
1answer
164 views

Function that calls another function with list of arguments doesn't work

In my .bash_aliases I have defined a function that I use from the command line like this: search -n .cs -n .cshtml -n .html SomeTextIWantToSearchFor /c/code/website/ /c/stuff/something/whatever/ ...
1
vote
0answers
71 views

How to pass commandline arguments larger than 131k? [closed]

I want to get data out of a Virtualbox VM. You can define variables (called guestproperties) via commandline, which can be accessed from both the host and the VM. The amount of data for such a ...
2
votes
2answers
70 views

Optional arguments after or before the mandatory arguments?

I'm creating a shell script and I need it to take two mandatory arguments and one optional. How do I check that? In most scripts I've seen, the optional arguments are passed before the mandatory ones, ...
2
votes
1answer
47 views

Why am I getting “too many arguments”

Here's a part of my script that is telling me that I have too many arguments on line 3: #!/bin/bash export LC_ALL='C' if [ `echo "*file 2" | grep -o ^.` = '.' ] then echo success fi Anybody ...
0
votes
0answers
18 views

Find out which arguments an application supports

I have iOS Simulator.app on Mac. Is there a way to find out what arguments can be passed to the app through the command line?
1
vote
2answers
104 views

Check that a bash script has exactly two arguments which are directories

I'm writing a bash script that compares two directories, but I'm not sure how to check conditions For example, if the user enters 1 arg instead of 2 (we need 2 since we're comparing two directories), ...
1
vote
1answer
62 views

Understanding grep and pipes in linux

I came across this post which explains my problem. Suppose there is a file called file.txt which contains "foo World". The answer posted by Tyler explains a lot however I am confused as to how cat ...
4
votes
1answer
86 views

How can I create an alias that passes additional arguments?

I have an executable that I use often: /dir1/dir2/dir3/dir4/executable argv[1] argv[2] argv[3] I know that I can set an alias for the executable: alias myexecutable = ...
3
votes
2answers
41 views

How is it possible to execute a command with an unknown number of arguments in a POSIX shell?

I want to search for multiple words inside the current directory. To accomplish this I use something like this. grep -e "word1" -e "word2" -R . This works fine. Taking this one step further, I ...
1
vote
2answers
157 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
249 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
100 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
527 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
41 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
134 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
383 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
115 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
283 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
60 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
163 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 ...
20
votes
1answer
419 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 ...
34
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
73 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
439 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
511 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
99 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
63 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 ...
8
votes
3answers
1k 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
93 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
291 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 ...
3
votes
3answers
208 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
409 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 ...
7
votes
3answers
11k 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
229 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 ...
5
votes
2answers
6k 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
99 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
160 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
5k 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 ...
10
votes
3answers
1k 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
430 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
43 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
672 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
153 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
531 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
87 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
2k 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?