You are not logged in.
Pages: 1
From wiki: https://wiki.archlinux.org/index.php/Pa … l_packages
I have this command: pacman -Qi wget | awk -F'[:<=>]' '/^Depends/ {print $2}' | xargs -n1 | sort -u
But I'd like to alias the above command but accept the package-name as input from user, how to?
Last edited by super_trash (2018-09-07 03:44:16)
Offline
Aliases do not take parameters, use a function:
somename() { pacman -Qi "$@" | awk -F'[:<=>]' '/^Depends/ {print $2}' | xargs -n1 | sort -u; }"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Aliases do not take parameters, use a function:
somename() { pacman -Qi "$@" | awk -F'[:<=>]' '/^Depends/ {print $2}' | xargs -n1 | sort -u; }
True, but I'd embed it to alias by adding `;somename` at the end.
Solved.
Offline
Why would you do that? There's no reason to create a function just to create an alias to it.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Why would you do that? There's no reason to create a function just to create an alias to it.
I had trouble to alias now, can you help.
I try: alias cld='f() { pacman -Si "$@" | awk -F\'[:<=>]\' \'/^Depends/ {print $2}\' | xargs -n1 | sort -u };f'
but got error: parse error near `}'
I tried to escape ' character.
I need to put all pacman-things to one alias file.
Offline
You need a semicolon after 'sort -u' - but again, this makes no sense as an alias, just leave it a function.
EDIT: the semicolon is needed, but may not be sufficient. I'm not sure exactly where the problem is, but I see no point in debugging a needlessly complex function definition within an alias. Just define a function and be done with it.
Last edited by Trilby (2018-09-07 04:06:33)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Or use expac since it's super efficient and also not vulnerable to forgetting to use LC_ALL=C when using awk to match English strings:
expac -l '\n' '%E' wget| sort -uLast edited by eschwartz (2018-09-09 09:14:57)
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Pages: 1