Hi I am trying to back up files with cshell script .And I have to pass the size of the files,the backup directory and the file
Could you help me with advises ,and am I useing find right
thanks
#!/bin/csh
if( $2 =="") then
echo "Please provide correct parameters"
echo "corect call is: $0 <size> <target_directory> <filename list>"
exit
endif
if (!(find ./-name "$2"))
then
echo "File with the same name exist allready"
exit
endif
tar does that of course, since it's hardly possible to create a file in a nonexistent directory. Even if you write it in csh it'd make sense to use tar somehow.
Why are you using csh, anyway? Any other shell would be better. If you absolutely insist on it, here's how you check for a directory in csh:
#!/bin/csh
set DIR="asdf"
if ( -d "$DIR" ) then
echo exists
endif
#!/bin/csh
if( $2 =="") then
echo "Please provide correct parameters"
echo "corect call is: $0 <size> <target_directory> <filename list>"
exit
endif
if ( -d "$2 ")
then
echo "File with the same name exist allready"
exit
endif
You are beginning to discover for yourself just what's wrong with the C-shell. I think you missed some spaces, but the ad-hoc parser throws a wobbly and returns an error that has nothing to do with the problem.
#!/bin/csh
if ( $2 == "" )
then
echo "Please provide correct parameters"
echo "corect call is: $0 <size> <target_directory> <filename list>"
exit
endif
if ( -d "$2" )
then
echo "File with the same name exist allready"
exit
endif