nixers
[SOLVED] Alias' and apostrophes - Printable Version
+- nixers (https://nixers.net)
+-- Forum: Development & Graphics (https://nixers.net/Forum-Development-Graphics)
+--- Forum: Programming On Unix (https://nixers.net/Forum-Programming-On-Unix)
+--- Thread: [SOLVED] Alias' and apostrophes (/Thread-SOLVED-Alias-and-apostrophes)


[SOLVED] Alias' and apostrophes - Phyrne - 30-08-2012

Hoping someone can help me here, it's probably rather simple!
I have a snippet of shell script I want to assign an alias to, but it has apostrophes and quotation marks in it. Is there any way to assign an alias to this?

Code:
awk 'BEGIN{while (("pacman -Qi" |getline) > 0){ if ($0 ~ /Name/) {name=$3};\

{if ($0 ~ /Size/) {size=$4/1024;printf "%-25s %d Mb\n", name, size|"sort -k2 -n"}}}}'

I'm using zsh, in case that makes a difference :)
I suppose I could always just put it into a script and export the directory to my zsh.rc, but it'd be nice to have it in my alias' section!
Thanks in advance for any help


RE: Alias' and apostrophes - yrmt - 30-08-2012

Put that in a little script:

Code:
#!/bin/sh
awk 'BEGIN{while (("pacman -Qi" |getline) > 0){ if ($0 ~ /Name/) {name=$3};\

{if ($0 ~ /Size/) {size=$4/1024;printf "%-25s %d Mb\n", name, size|"sort -k2 -n"}}}}'

chmod it +x and put it in your path ;)


RE: Alias' and apostrophes - Phyrne - 30-08-2012

(30-08-2012, 02:22 PM)Beastie Wrote: Put that in a little script:

Code:
#!/bin/sh
awk 'BEGIN{while (("pacman -Qi" |getline) > 0){ if ($0 ~ /Name/) {name=$3};\

{if ($0 ~ /Size/) {size=$4/1024;printf "%-25s %d Mb\n", name, size|"sort -k2 -n"}}}}'

chmod it +x and put it in your path ;)

Yeah that's what I thought I'd have to do, was just hoping there might be the cleaner way of keeping it in my aliases. Thanks for confirming though :D


RE: [SOLVED] Alias' and apostrophes - Phyrne - 31-08-2012

(31-08-2012, 12:24 AM)NeoTerra Wrote: Glad to see this thread marked solved. Even if you have common solutions to problems, it's good to see them posted here. One man's solution is another man's treasure.

Yup! Always helpful to have stuff like this around I guess :)


RE: [SOLVED] Alias' and apostrophes - pvtmert - 05-03-2014

may be very very late repy but what about making it a function then calling it?