carlosmp
asked on
script to read file
Hi,
I have a file called storage.cfg, and would like to be able to list the directory if it contains a certain line.
sample file:
If I were to do it manually I would look for the lines after a (dir|nfs|iscsi|lvm) and if the content line contains vztmpl, then I need to grab the path, append /template/cache and run ls -l on the directory. The indentations are tab characters.
ls-l /var/lib/vz/template/cache
ls -l /mnt/pve/OpenF-prox/templa te/cache
ls -l /mnt/pve/OpenF-voip/templa te/cache
I don't know where to start with this...
TIA,
Carlos.
I have a file called storage.cfg, and would like to be able to list the directory if it contains a certain line.
sample file:
dir: local
path /var/lib/vz
content images,iso,vztmpl,rootdir
maxfiles 1
nfs: OpenC1-prox
path /mnt/pve/OpenF-prox
server 1.1.1.1
export /mnt/data/openf/ProxNFS
options vers=3
content images,iso,vztmpl,rootdir,backup
maxfiles 2
nfs: OpenC1-voip
path /mnt/pve/OpenF-voip
server 1.1.1.1
export /mnt/data/openf/ProxVoIP
options vers=3
content images,iso,vztmpl,backup,rootdir
maxfiles 1
If I were to do it manually I would look for the lines after a (dir|nfs|iscsi|lvm) and if the content line contains vztmpl, then I need to grab the path, append /template/cache and run ls -l on the directory. The indentations are tab characters.
ls-l /var/lib/vz/template/cache
ls -l /mnt/pve/OpenF-prox/templa
ls -l /mnt/pve/OpenF-voip/templa
I don't know where to start with this...
TIA,
Carlos.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.