Skip to main content
More precise title, markup fixes, tiny grammar fixes
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Count the number of character occurancelines ending in files"*"

I have several files in a directory with this kind of content:

Wood *
Nails
Large Hammer *
Wood *
Nails
Large Hammer *

Some names have a star after them, some don't. I have multiple files with such content. In each file a product may or may not have a single star next to it. I need to make a bash script to count the number of star occurencesoccurrences for each individual product in all the files. For example, the output needs to be like this:

Wood 12
Yellow Lamps 6
Nails 4
...
Wood 12
Yellow Lamps 6
Nails 4
...

Which means that in all the files it found 12x a star next to Wood, 6x a star next to the lamps, etc...

It's pretty easy to parse it in C for example, but iI don't want a binary to run,. I want a shell script, and I'm not as versatile with grep and awk, which I'm sure I need here.

I know how to count the stars per se, but I'm not sure how to keep track of which star count belongs to which product.

Count the number of character occurance in files

I have several files in a directory with this kind of content:

Wood *
Nails
Large Hammer *

Some names have a star after them, some don't. I have multiple files with such content. In each file a product may or may not have a single star next to it. I need to make a bash script to count the number of star occurences for each individual product in all the files. For example the output needs to be like this:

Wood 12
Yellow Lamps 6
Nails 4
...

Which means that in all the files it found 12x a star next to Wood, 6x a star next to the lamps, etc...

It's pretty easy to parse it in C for example, but i don't want a binary to run, I want a shell script, and I'm not as versatile with grep and awk, which I'm sure I need here.

I know how to count the stars per se, but I'm not sure how to keep track of which star count belongs to which product

Count lines ending in "*"

I have several files in a directory with this kind of content:

Wood *
Nails
Large Hammer *

Some names have a star after them, some don't. I have multiple files with such content. In each file a product may or may not have a single star next to it. I need to make a bash script to count the number of star occurrences for each individual product in all the files. For example, the output needs to be like this:

Wood 12
Yellow Lamps 6
Nails 4
...

Which means that in all the files it found 12x a star next to Wood, 6x a star next to the lamps, etc...

It's pretty easy to parse it in C, but I don't want a binary to run. I want a shell script, and I'm not as versatile with grep and awk, which I'm sure I need here.

I know how to count the stars per se, but I'm not sure how to track which star count belongs to which product.

Became Hot Network Question
Source Link

Count the number of character occurance in files

I have several files in a directory with this kind of content:

Wood *
Nails
Large Hammer *

Some names have a star after them, some don't. I have multiple files with such content. In each file a product may or may not have a single star next to it. I need to make a bash script to count the number of star occurences for each individual product in all the files. For example the output needs to be like this:

Wood 12
Yellow Lamps 6
Nails 4
...

Which means that in all the files it found 12x a star next to Wood, 6x a star next to the lamps, etc...

It's pretty easy to parse it in C for example, but i don't want a binary to run, I want a shell script, and I'm not as versatile with grep and awk, which I'm sure I need here.

I know how to count the stars per se, but I'm not sure how to keep track of which star count belongs to which product