processing line in file

Hi

I amtrying to read the lines from a file, these lines are absolute paths in the system. I want to check if these paths exists, if they doesn't I want to create that path and put a file in that location/path.

I had no trouble filtering these paths out using awk, grep, uniq etc but when it comes to write my own lite script that should process these lines I am clueless. I have been reading up awk but it seems a litle complicated, am I gooing in the right direction, what is the easiest way to solve this, what tools should I use?

Thanks in advance.

Cheers
fable00

I just tried this and it seems I have a lead now. :slight_smile:

cat /etc/hosts | while q=$(line); do echo $q; done

but feel free to give sugestions on how I should handle the logic with checking the if the file structure exists.

Cheers
fable00

List of files with complete path

list.txt
/dir/a
/dir/b
/dir/c
while read file
do
if [ ! -d "$file" ] ; then
mkdir -p "$file"
touch "/$file/newfile"
fi ;
done < list.txt

That should be a starting point.

Not tested.

Thanxs, it so great when you pick up and learn something new, it worked vino :slight_smile: , thanxs again.

Hi ,
I am trying to write a script which picks up each entry ( list of Filesystems in a file ) from a file and then checks whether that Filesystem was backed up or not ?

# Script to check for the backups of some particular Filesystems backup status
cat <one f ile >
while q=$(line)
do
echo $q > FS
mminfo -c gbo472b -t yesterday | grep $FS
if [ $? -eq 0 ]
then
echo "$FS was backed up "
else
echo "$FS was not backed up"
fi
done

but it is not working ..pls let me know the problem.

This script looks like it was written for sh/ksh/bash. If so, the syntax seems to be incorrect.

#Script to check for the backups of some particular Filesystems backup status
######## cat <one f ile > # hashed this out. you don't need this
while read line; do
mminfo -c gbo472b -t yesterday | grep $line
if [ $? -eq 0 ]; then
   echo "$FS was backed up "
else
   echo "$FS was not backed up"
fi
done < /path/to/file/with/filesystem_list

I have no idea what mminfo does, just fixed some syntax errors in the script.

Hi ,

Thanks for you reply.

But I wanted the script to pick each Filesystem status from the file and see whether it was backed up or not.

Looks like the way you are starting the script is wrong.
while read line; do
mminfo -c <clinet_name> -t yesterday | grep $line

My question is with out defining the variable line how can grep understand it.

Please reply back..

Thanks

From the ksh man page:

See the below code:

while read line; do
 :
 :
done < /path/to/file/with/filesystem_list

Here, the read command is having the standard input redirected from the file "/path/to/file/with/filesystem_list".

Thanks for the clarification..