How to run a command in another command?
I am not sure how to ask this, sorry.
if I had a code like this Code:
# grep -a ": " md5list.txt | cut -f2,3 -d How can I run the command basename for each line of the output? basename {(grep -a ": " md5list.txt | cut -f2,3 -d )} EDIT: A little more clarity on what im doing: I didn't realize that 'md5sums' was a link to a nice formatted page. So I copied all packages here and put them into a text file. I decided to write a script that put all of these in that format. So basically, even though I have already ran the md5sum -c 'md5sum-list' I still want to finish this small project because I am learning a ton. |
Hi
This should work: Code:
for filename in "$( grep -a ": " md5list.txt | cut -f2,3 -d " " )" ; do basename "$filename" ; done Philip |
Quote:
This is similar to your code but using {} instead of $()... Code:
for i in {1..5}; do echo $i; done What about eval?? Would my code need that? I do not understand $() in your example. what does this do? what is it called? Code:
for i in $(eval echo "{$START..$END}") |
I worked with your code and came up with a way to iterate through the file, but still I can not figure how to run baseline.
Code:
# for i in {1..200}; do sed '$i,0!d' md5list.txt | grep -a ": "; done |
Quote:
Quote:
Quote:
This is a great reference guide for bash scripting: Advanced Bash-Scripting Guide |
Wish I knew what the md5list.txt file contained. Hard to help when that's not available. I am assuming it's the normal output of md5sum.
This may be a better method: Code:
while read i I added a " " to the -d cause I wasn't sure what you were defining so I figured whitespace. |
Quote:
Yes, whitespace is correct. Because I was using the PDF document, I didn't realize that 'md5sums' was a link to a nice formatted page. So I copied all packages and md5 text here and put them into a text file. I decided to write a script that put all of these in that format. So basically, even though I have already ran the md5sum -c 'md5sum-list' I still want to finish this small project because I am learning a ton. I ran your script and got a syntax error near unexpected token 'done' |
All times are GMT -5. The time now is 01:00 PM. |