All Questions
20 questions
0
votes
0
answers
21
views
Understanding syntax of output from alias [duplicate]
I don't understand how to read the string and the escaping of the following output from listing aliases
> alias foo="echo 'hello'"
> alias
...
alias foo='echo '\''hello'\'''
...
It ...
0
votes
2
answers
245
views
How do I convert this script into an alias (MacOS, ZSH) [duplicate]
This script works fine when directly typed into the console:
N | find . -type f -iname "*.aac" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -acodec libmp3lame "${...
0
votes
2
answers
761
views
How can I define and use `alias` within `bash -c` with a one-line command?
I am trying to define and use alias within bash -c with a one-line command.
The command:
bash -c "eval $'df'"
works fine, but:
bash -c "eval $'alias df5=df\ndf5 -h'"
doesn't. Why, and how can I ...
10
votes
2
answers
2k
views
How to create alias with a command contains ' and " [duplicate]
A few posts ago someone asked how to show memory in percentage. Someone replied with:
free | awk '/^Mem/ { printf("free: %.2f %\n", $4/$2 * 100.0) }'
I was wondering if I can turn this command into ...
1
vote
2
answers
790
views
Setting an alias when double quotes and single quotes both fail
This question is not a duplicate of Why alias behave different than running bash command directly? because I have tried that solution and it hasn't worked. I replaced all my single quotes with double ...
1
vote
4
answers
2k
views
An Alias for Moving Files and Following Them to Their Destination
I’m trying to write a script – or an alias, to be more precise – which allows me to move files and follow (cd) them to their target directory. The accepted answer to this question suggests this code:
...
1
vote
1
answer
1k
views
Alias accepting variables from the result of evaluation [duplicate]
I was trying to define an alias that helps me to cd to the directory that is created most recently, and I'm using the following in my .bashrc:
alias cdlatest="latestdir=$(ls -td -- */|head -n 1); cd $...
10
votes
2
answers
3k
views
How to stop .bashrc from running sub-command in alias at startup? [duplicate]
I have added an alias command to kill my guake terminal to my .bashrc
alias killguake="kill -9 $(ps aux | grep guake | head -n -1 | awk '{print $2}')"
But the problem is, the sub-command i.e. ps aux |...
0
votes
1
answer
1k
views
How to launch Notepad++ from the Cygwin command line via an alias?
This is what I tried.
$ alias n++='(cd `dirname $1`; "/cygdrive/c/Program Files (x86)/Notepad++/notepad++.exe" `basename $1`)'
alias n++='(cd `dirname $1`; "/cygdrive/c/Program Files (x86)/Notepad++/...
4
votes
2
answers
1k
views
Alias doesn't seem to read from STDIN
I'm looking for an alias to convert hex from hexdump output into "Python's" hex notation:
$ echo "5f 74 34 0c c9 7b 9f f8 7a 7c 46 ff ff 5c 31 26" | sed 's/ */\\x/g' | awk '{print "\\x"$0}'
\x5f\...
1
vote
1
answer
2k
views
How do I nest quotes four deep?
I have a complex command that I'm running in watch to nag users to get out of a filesystem when I need to unmount it. The following is working
watch -ben5 $'lsof /mnt/unfs && ps --no-headers ...
12
votes
1
answer
1k
views
bashrc lazy substitution
How does one get ~/.bashrc aliases to evaluate $() substitutions at run time, instead of at the time that ~/.bashrc is executed (when opening a terminal)?
I run this command often enough that I would ...
11
votes
3
answers
9k
views
Single or Double quotes when defining an alias?
I know that contents of double quotes are expanded, whereas the contents of single quotes are not, such that
echo '$1'
gives
$1
where as
echo "$1"
gives
<the argument - blank in this ...
2
votes
2
answers
2k
views
Trying to make aliases that open the last modified file
One thing that I frequently do is edit the most recently modified files, so instead of typing "ls -lr" and then "vim lastfile", I thought I would make some shortcuts in my ~/.bash_profile file:
alias ...
2
votes
2
answers
2k
views
An alias for a command to kill stopped jobs
I wanted to add an alias to my .bashrc so that I could kill all stopped jobs with a command like kill_stopped. I am aware that kill `jobs -p` can be used to accomplish this but I'd rather have an ...