Yeah... I'm with nix422.
I don't follow... At least, I'm not confident that I know what you're trying.
From what you posted:
Code:
for i in `grep Installing installing.log.file | awk '{print $2}'`
do echo $i >> filename
Ok, so you're trying to loop line-by-line through a grep-awk pipeline.
The grep is supposed to report only lines that include 'Installing" from the file named "installing.log.file". The awk removes all but the second column from each matching line--presumably leaving the package name.
The next line simply appends the package name verbatim to the end of a file named "filename".
There are some better ways of doing this kind of thing. Personally, I don't like trying to shove a whole big bunch of names into a long "for x in some_really_long_list" but prefer loops. For instance:
Code:
#!/bin/bash
grep Installing installing.log.file | \
awk '{print $2}' | \
while read packageName ; do
echo ${packageName}.rpm >> filename # as demonstrated by nix422
done
Quote:
Originally Posted by mrjawz
File not found is the most common error, Im receiving.
|
Nothing in your post suggests a "file not found" error
unless installing.log.file is the wrong filename or it is saved in a different directory--which would require a full path to reference the file.
EDIT:
Forgot to mention--the "better way" of doing such things. This can all be rolled into a single sed command.
Code:
sed -rn '/\bInstalling\b/ s@[^[:space:]]+[[:space:]]+([^[:space:]]+).*@\1.rpm@p' installing.log.file
You can then redirect the output of the command to filename like you did earlier.
You could probably do something similar with awk, but I'm not that familiar with it.