|
|
#1 |
|
Prospect
Join Date: Sep 2003
Location: Toronto, ON, Canada
Posts: 18
|
Hi all,
I'm working on a hint for the main site, but need to know how to embed a single quote when adding an alias command to one's .login file. For example if I want to echo out the phrase "can't" every time I type the command "test" I might make an alias like so: Code:
alias test 'echo can\\'t' The "alias" command takes two parameters so the single or double quotes are necessary around the second parameter to keep it all together (in this simple example you can do without them but for anything complex they are necessary). The real alias command I'm trying to get accepted is this (which will be posted to the main site as soon as I can figure out this little problem): Code:
alias dureport 'du -Ps * | awk '{printf "%12d\t%s\n", $1, substr($0,index($0,$2),80)}' |sort -r'
As you can see, awk requires the single quote characters to do its thing but I can't get them to embed properly as a parameter of the alias command. But don't worry about that big ugly string: if someone knows how to fix the problem with that simple 'echo' command I think that should solve my issue with the longer string too. Thanks, Colin. Last edited by cfoster; 10-08-2003 at 11:29 AM. |
|
|
|
|
|
#2 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
1) To include a single-quote in the body of a csh or tcsh alias, use the 4 characters '\''
2) If you use the -k option to 'du', it gives the size in KB rather than in (512 byte) blocks. This gives sizes that are in more familiar units and directly comparable with what you see with 'ls -l' 3) I use 'du -skx * | sort -nr' to get the ordered list of disk space use that you are getting with your command |
|
|
|
|
|
#3 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
another blow against the csh family of shells; quoting nightmares.
simplify and use the tool's switches. i find that: Code:
$ du -xack /path/to/ 2>/dev/null | sort -nr | head -55 and the head makes it fit in my terminal window, and the redirect errs to null keeps access errs quiet as a bash function for the enlightened: Code:
lhf () # list heavy files
{
du -xack "$@" 2>/dev/null | sort -nr | head -55
}
|
|
|
|
|
|
#4 |
|
Prospect
Join Date: Sep 2003
Location: Toronto, ON, Canada
Posts: 18
|
I think I scoured every related man entry for a workaround option... except sort. Yes -n simplifies things, greatly, doesn't it?!
Good tip on escaping quote characters, just the same! Thanks! -Colin. |
|
|
|
![]() |
|
|