Issue
I'm trying to grab only "name_of_package.rpm" from a list of 10,000+ packages available for CentOS 7. I've tried various iterations/combinations of awk and grep with no avail. I've tried using Google and a few ideas from other questions asked here, but nothing seems to work for me at the moment. Any assistance is appreciated!
awk -F '\w' '{print $2}' /data/rpm-list
cat /data/rpm-list | grep -o "\w*\.rpm\w*"\
cat /data/rpm-list | grep -o "*\.rpm"
This is what I'm trying to parse through:
[ ] 389-ds-base-1.3.8.4-15.el7.x86_64.rpm 2018-11-12 14:21 1.7M
[ ] 389-ds-base-devel-1.3.8.4-15.el7.x86_64.rpm 2018-11-12 14:21 271K
[ ] 389-ds-base-libs-1.3.8.4-15.el7.x86_64.rpm 2018-11-12 14:21 698K
[ ] 389-ds-base-snmp-1.3.8.4-15.el7.x86_64.rpm 2018-11-12 14:21 167K
I just wanted the "name_of_package.rpm" without the "[ ]", dates, or sizes. I fully intend to pass this list through a script that will download everything with its dependencies to a personal lab server that I can use offline. Cheers!
Solution
From your shown sample input looks like you could simply do(again fully based on your shown sample Input_file).
awk '{print $3}' Input_file
EDIT: In case you are more interested to know about field numbers with their field values then you could run following command too.
awk '{for(i=1;i<=NF;i++){print "Field number is: "i " Field value is: "$i}}' Input_file
Answered By - RavinderSingh13