Skip to main content

All Questions

Tagged with
2 votes
1 answer
4k views

Passing a git command as an argument

I'm trying to automate some tedious parts of a student job I'm working on. Basically, the goal is to clone a bunch of git repositories (which I already have working), then run the same git checkout ...
Trevor Muraro's user avatar
0 votes
2 answers
498 views

bash script function argument problem [duplicate]

Not sure why this is producing error. This is a test code emulating my real code. I want to write a wrapper for find and want to allow for any argument, so I'm wrapping each arg in single quotes. #...
codechimp's user avatar
  • 207
3 votes
2 answers
10k views

Passing paths with spaces as arguments

I am having difficulty in passing some string variables having spaces in them as arguments to a program. For debugging and showing the arguments being passed, I created a demo Python script -: #####...
Anmol Singh Jaggi's user avatar
21 votes
3 answers
16k views

How does 'find -exec' pass file names with spaces?

If I have a directory containing some files whose names have spaces, e.g. $ ls -1 dir1 file 1 file 2 file 3 I can successfully copy all of them to another directory like this: $ find dir1 -mindepth ...
EmmaV's user avatar
  • 4,087
1 vote
2 answers
2k views

UNC Argument in bash scipt

I want to create a bash script with a "pure" UNC (i.e. I do not want to escape the backslashes literally) as an argument, i.e. something like: ./foo \\my\share\is\here However, as is natural, the ...
trikelef's user avatar
  • 411
1 vote
2 answers
578 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 + "$...
Jacques MALAPRADE's user avatar
18 votes
2 answers
12k 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 ...
neuviemeporte's user avatar
52 votes
3 answers
75k views

Add arguments to 'bash -c'

Let's 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 ...
Slartibartfast's user avatar
1 vote
1 answer
483 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 ...
dempap's user avatar
  • 725
1 vote
1 answer
2k 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 ...
user72685's user avatar
  • 333
3 votes
2 answers
531 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 ...
Andrew Cheong's user avatar
0 votes
2 answers
3k 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 ...
Reloader's user avatar
  • 103
14 votes
4 answers
19k views

How to prevent command injection through command options?

I have an wrapper application where I need to let the user specify custom options to pass to a simulator. However, I want to make sure the user doesn't inject other commands through the user options. ...
Victor L's user avatar
  • 409
12 votes
2 answers
23k views

Pass arguments to function exactly as-is

I have the following function: bar() { echo $1:$2; } I am calling this function from another function, foo. foo itself is called as follows: foo "This is" a test I want to get the ...
Konrad Rudolph's user avatar
7 votes
3 answers
2k views

Bash : command line with optional arguments

I'm running this kind of code: #!/usr/bin/env bash set -u exclude1='--exclude=/path/*' exclude2='--exclude=/path with spaces/*' exclude3='' # any 'exclude' can be empty tar -czf backup.tgz "$...
Gregory MOUSSAT's user avatar

15 30 50 per page