The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Multiple file processing - 1st line only to process - search/match substring toneatlondon Shell Programming and Scripting 2 01-02-2008 09:20 PM
AWK Multi-Line Records Processing RacerX Shell Programming and Scripting 10 10-18-2007 09:46 PM
processing a file with sed and awk manouche Shell Programming and Scripting 4 10-11-2007 05:25 PM
Processing a CSV file janemary.a High Level Programming 1 05-11-2007 07:27 AM
Have a shell script check for a file to exist before processing another file heprox Shell Programming and Scripting 3 11-14-2006 03:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-17-2006
fablef00 fablef00 is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 3
Question 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
  #2 (permalink)  
Old 01-17-2006
fablef00 fablef00 is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 3
I just tried this and it seems I have a lead now.

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
  #3 (permalink)  
Old 01-17-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
List of files with complete path


Code:
list.txt
/dir/a
/dir/b
/dir/c


Code:
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.
  #4 (permalink)  
Old 01-17-2006
fablef00 fablef00 is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 3
Thanxs, it so great when you pick up and learn something new, it worked vino , thanxs again.
  #5 (permalink)  
Old 01-20-2006
new2prog new2prog is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 9
need help in almost a similar case

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.
  #6 (permalink)  
Old 01-21-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
This script looks like it was written for sh/ksh/bash. If so, the syntax seems to be incorrect.

Code:
#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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0