Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [EN] grep Replaces (and show result *with* filename)  (Read 11397 times)

Offline michaa7

  • User
  • Posts: 2.379
[EN] grep Replaces (and show result *with* filename)
« on: 2013/05/31, 13:54:18 »
I try to figure out whether some (texlive) packages had become obsolete or aren't built yet (the situation now lasts about a week). In the first case I can let them go, in the second case I can't.

I thought I could grep for "Replace" in the output of "apt-cache show texlive*"
Code: [Select]
apt-cache show texlive* | grep Replaces:
which actually shows that those files are *replaced*.
Unfortunately it does not show which package is the one which replaces some other one. And as "texlive*" covers more than the installed files I don't know which packages I need to install.

The flag "-H" should show the files name, but actually it shows "Standardeingabe" (I think this is "stdin") for all matches (probably due to the fact that the input is piped).

Does anybody has a clue how to extend the "code" such that it provides the name of the file/package which replaces "whatever".
Ok, you can't code, but you still might be able to write a bug report for Debian's sake

xaos52

  • Guest
RE: grep Replaces (and show result *with* filename)
« Reply #1 on: 2013/06/03, 12:36:27 »
You must escape the '*'
So use
Code: [Select]
apt-cache show 'texlive*' | grep Replaces
or
Code: [Select]
apt-cache show texlive\* | grep Replaces

To capture the name of the package you will probably have to resort to 'awk'.

Offline michaa7

  • User
  • Posts: 2.379
RE: grep Replaces (and show result *with* filename)
« Reply #2 on: 2013/06/03, 13:17:16 »
Thanks!

Escaping might be the syntacticly clean version, but there is no difference in output no matter whether I escape or not.

As to 'awk', I'm *afraid* you are right, because it's japanees to me. I am completely lost with it.
Ok, you can't code, but you still might be able to write a bug report for Debian's sake

xaos52

  • Guest
RE: grep Replaces (and show result *with* filename)
« Reply #3 on: 2013/06/03, 18:08:55 »
Code: [Select]
{
    if ( $0 ~ /Package:/ ) { package=$0 }
    if ( $0 ~ /Replaces:/ ) { printf "%s %s\n\n",package,$0 }
}
save this somewhere.
Then run
Code: [Select]
apt-cache show texlive\* | awk -f <path-to-the-awk-script>

Offline michaa7

  • User
  • Posts: 2.379
RE: grep Replaces (and show result *with* filename)
« Reply #4 on: 2013/06/04, 21:54:34 »
Thanks!

Meanwhile I solved this in an other way:

Code: [Select]
# apt-cache show texlive* | egrep "^Package|Replaces" | grep "Replaces" -B1

Not really elegant, but at my level of knowledge ;-) .

From what I read so far I feel awk would be a blind alley for me.
Do you know by chance an appropriate, but free manual for shell scripting for absolut beginners? The ones I found googeling did not explain at the right level. I need something explaining basics only (variables, loops), something for fools, something where I may have success with little steps?
Ok, you can't code, but you still might be able to write a bug report for Debian's sake

Offline Geier0815

  • User
  • Posts: 593
RE: grep Replaces (and show result *with* filename)
« Reply #5 on: 2013/06/04, 22:26:54 »
THIS is the best guide thru bash. The problem is that bash is not as easy as it seems...
Wenn Windows die Lösung ist...
kann ich dann bitte das Problem zurück haben?

Offline michaa7

  • User
  • Posts: 2.379
RE: grep Replaces (and show result *with* filename)
« Reply #6 on: 2013/06/04, 22:58:28 »
Thanks Geier0815.
I have now doubt it's the best ... for you. I will bookmarkt it and give it a try. Still, I'd like to find something for me where neither the first word is "Advanced" nor it actually being written for advanced users ...

I now give thisone a try and we'll see where it leads ...
http://tldp.org/LDP/Bash-Beginners-Guide/html/
Ok, you can't code, but you still might be able to write a bug report for Debian's sake