Skip to main content

All Questions

Tagged with
0 votes
2 answers
236 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 "${...
Vadorequest's user avatar
0 votes
2 answers
701 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 ...
Franck Dernoncourt's user avatar
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 ...
BlackCrystal's user avatar
1 vote
2 answers
759 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 ...
mas's user avatar
  • 1,909
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: ...
bleistift2's user avatar
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 $...
cdnszip's user avatar
  • 253
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 ...
Muhammad Tahir's user avatar
0 votes
1 answer
982 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++/...
Chloe's user avatar
  • 538
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\...
Juicy's user avatar
  • 3,955
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 ...
Jeff's user avatar
  • 1,282
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 ...
dotancohen's user avatar
  • 16.1k
11 votes
3 answers
8k 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 ...
Greenonline's user avatar
  • 1,870
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 ...
Nick's user avatar
  • 163
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 ...
Zach Halle's user avatar
38 votes
3 answers
31k views

How to escape single quotes correctly creating an alias [duplicate]

I've been given this one-liner to know how much memory my processes consume. $ ps -u $USER -o pid,rss,command | \ awk '{print $0}{sum+=$2} END {print "Total", sum/1024, "MB"}' Now I'd like to ...
Paolo's user avatar
  • 17.6k

15 30 50 per page