Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Viewing all articles
Browse latest Browse all 102

Using awk for a bash script that defines a "minimum packages set"

$
0
0

I would like to write a script with the following requirements:

  • in input, get a list of packages available via apt. In there you may have some packages that are automatically installed by other packages in list.
  • in output, provide the same list without the packages that depends from other packages in list.

In other terms, I want to do in bash what the user Francois G did in this answer

Maybe something like this already exists, but sometimes I like to write scripts to improve my bash-scripting and also for fun.

In my mind, I already designed the script, but I have a technical issue. Let's assume that I have the dependency list in this format (it's the way apt-rdepends put it):

useless-line-1useless-line-2useless-line-3item-1  fixed-string substring-1-1  fixed-string substring-1-2  fixed-string substring-1-3item-2  fixed-string substring-2-1  fixed-string substring-2-2item-3item-4  fixed-string substring-4-1  fixed-string substring-4-2  fixed-string substring-4-3  fixed-string substring-4-4

I want to extract the paragraph related to item-1 i.e.:

  fixed-string substring-1-1  fixed-string substring-1-2  fixed-string substring-1-3

I'm not an awk expert, but I think that it can suit my purposes. I'm not able to "build" the correct command. Due to the fact that item-2 may be not known, I tried:

# extract text between item-1 and the next line that starts without blank$ awk '/item-1/,/^[A-Za-z0-9]/' deplistitem-1

but item-1 already fits the condition ^[A-Za-z0-9], so it's not good. Moreover, I want to exclude item-1 and item-2 from the output.

Which is the best way to extract that portion of data?


Viewing all articles
Browse latest Browse all 102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>