0

Hi Experts

I've less idea abt unix shell script. my requirement is the shell script should take a input of a file name and shud check if that file name is present in the particular folder which is hardcoded. if not then wrtie the file there or if found write the fle in another location. is it possible to acheive this. ur help is highly appricicateed. pls copy fo mailprabhu@gmail.com for any good doc's on the same.

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by thekashyap
0

Read this.
This is what I'll tell you..

#!/bin/sh

hardcoded_folder="xxx"

#expected args:
# $1: Relative path of file to be checked. (relative to hardcoded path)
# $2: Abs path of "another location"
#
function my_function()
{
    f_2_check=$1
    another_location=$2

    #if -f $hardcoded_folder/$f_2_check then
    #file found, so write to another location
    #copy $hardcoded_folder/$f_2_check another_location/$f_2_check
    #else
    #file not found, so create it
    #touch $hardcoded_folder/$f_2_check
}

my_function file_2_check /another_location
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.