apt-cache search "google chrome" | awk '{print $1}' | perl -pe '$_ = "\033[1;29m$_\033[0m" if($. % 2)'
So is there any option of making a bash alias out of it? It works but I don't have a clue of how to pass an argument to replace "google chrome" in this case. Or is there any simpler way of doing it?
Also: Is there any way for showing an Architecture (apt-cache show) for each line? I was using gentoo previously and am always choosing hard way, I suppose...
Write it as a function using "$@"
for your parameters:
search() {
apt-cache search "$@" | awk '{print $1}' | perl -pe '$_ = "\033[1;29m$_\033[0m" if($. % 2)'
}
With this in your .bashrc
, you can search google chrome
.
#!/bin/bash
apt-cache search $@ | awk '{print $1}' |
while read line; do apt-cache madison $line; done |
sed 's/^ *//' |
perl -pe '$_ = "\e[34m$_\e[39m" if($.%2==1)' ;
echo -e "\e[49m"
That's what I've made. And it actually works :x
Here's another way:
apt-cache search "$1" |
awk '{ print (NR%2) ? "\033[1;29m-> " $1 "\033[0m" : "-> " $1 ;
system ("apt-cache show " $1 "| egrep \"^Package|^Version|^Architecture\"")
}'
I've also tried to accommodate your second request too ( apt-cache show
for each line) in the code above. Modify it if needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.