All Questions
9 questions
0
votes
1
answer
322
views
how to write function with nested commands [duplicate]
I'm trying to write a find and cd function like so:
findcd () {
cd "$(dirname "$(find '$1' -type '$2' -name '$3')")"
}
to be called like so:
find . f [FILE_NAME]
But it's ...
1
vote
1
answer
245
views
Run `git commit -m` with single quotes in zsh
I sometimes use characters such as ! and $ in commit messages, they need to be manually escaped, but not if you use single quotes like this git commit -m 'My $message here!'. I tried to write a ...
5
votes
3
answers
1k
views
Find exec sh: Shell variable not getting passed to subshell
Here is a simplified code that prints the name of Directory if it contains a Filename with same name as the parent directory and .md extension.
FIND(){
find . -type d -exec sh -c '
for d ...
1
vote
3
answers
619
views
SSH with Command Doesn't Run as an Alias
I have the following command to remote into a local server and tail -f the latest log file for an application that I have.
The command works perfectly fine from the command line -
ssh user@hostname ...
3
votes
1
answer
7k
views
Passing arguments with spaces and quotes to a script (without quoting everything)
The following works great on the command-line:
$ ffmpeg -i input.m4a -metadata 'title=Spaces and $pecial char'\''s' output.m4a
How do I parameterize this command and use it in a script/function? I ...
1
vote
1
answer
979
views
How to execute 'find' with 'sed' within a bash function
I'm trying to write a simple bash function to search-and-replace recursively down a directory, changing one string to another. Here's what I've got:
function sar () {
from="$1"
shift
to="$...
0
votes
2
answers
511
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.
#...
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 ...
5
votes
2
answers
4k
views
Bash: passing braces as arguments to bash function
I love using the following pattern for searching in files:
grep --color=auto -iRnHr --include={*.js,*.html,} --exclude-dir={release,dev,} "span" .
I'd like, however, to have this one wrapped into a ...