0

This is a follow-up query on allpackages.txt.gz has two different file-sizes?

$ wc -l allpackages.txt 
57725 allpackages.txt

I looked at the output and it says 57725 -6 the header files which is the grand total of 57719 packages but as shared in the comments on http://linux.koolsolutions.com/2008/12/19/counting-number-of-packages-under-debian-linux/#comment-10014 the following command should work but doesn't.

$ tail -n +7 allpackages.txt | cut -d’ ‘ -f1 | cut -d’-‘ -f1 | uniq | wc -l
cut: cut: the delimiter must be a single character
Try 'cut --help' for more information.
the delimiter must be a single character
Try 'cut --help' for more information.
0

Can somebody help in couple of ways :-

a. Decoding what the command itself tries to do ? I know that tail is used to give the last 10 odd words and cut is when you are trying to remove some sections of the file.

If needed would share the allpackages.txt somewhere so people can figure out the best way to know the unique number of packages therein.

https://www.dropbox.com/sh/9p03q138xx9nxvb/AAAukls-UnxRZwoCPwx4HwLAa?dl=0

6
  • You need to change backqoutation in -d parameter to ordinary '
    – fazie
    Commented Oct 8, 2014 at 6:06
  • Of course, the number of packages isn't a good estimator for the number of "applications". Consider checking the number of source packages, or the number of files in /usr/bin/ (in the Contents.gz file)
    – o11c
    Commented Oct 8, 2014 at 6:52
  • @fazie I tried tail -n +7 allpackages.txt | cut -d' ‘ -f1 | cut -d'-‘ -f1 | uniq | wc -l' but it didn't improve anything. I still got the same error as before. If possible, share how the command should look. @o11c Again the query, how do I check the number of source packages? I'm looking for an easy way. I didn't get the latter part of your answer as well. Even if the number of source packages is small/less/conservative would be ok, just need to have some way to get authoritative answers.
    – shirish
    Commented Oct 8, 2014 at 7:38
  • Lose the quotes, you're still not using the plain quote sign (I can see the left one is different from the second one). You don't need quotes around the -, and use -d\ for the space.
    – wurtel
    Commented Oct 8, 2014 at 8:43
  • wurtel, it would be so easy if you would have just have done it. I tried tail -n +7 allpackages.txt | cut -d' -f1 | cut -d' -f1 | uniq | wc -l that didn't work, I tried tail -n +7 allpackages.txt | cut -d\ -f1 | cut -d\ -f1 | uniq | wc -l that didn't work. Let's take this section wise and see what works.
    – shirish
    Commented Oct 8, 2014 at 22:02

1 Answer 1

0

You showed the command: tail -n +7 allpackages.txt | cut -d’ ‘ -f1 | cut -d’-‘ -f1 | uniq | wc -l. This contains non-ASCII quotes, which certainly isn't what was intended.

Try this instead:

tail -n +7 allpackages.txt | cut -d' ' -f1 | cut -d- -f1 | uniq | wc -l

Here's what the members of the pipeline do:

  • tail -n +7 prints a file starting at line 7;

  • cut -d' ' -f1 keeps the first field, using a single space as a separator;

  • cut -d- -f1 keeps the first field, using a minus sign (-) as a separator;

  • uniq compresses runs of identical lines into a single line;

  • wc -l prints the line count.

So, the entire pipeline ignores the first six lines of your file, and then attempts to count the unique values at the selected field. (This assumes that the input is sorted so that the values to be squashed together come in sequence, if this isn't true, a call to sort, perhaps sort -u, could be used).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .