•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,423 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,608 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 1360 | Replies: 1
![]() |
•
•
Join Date: Apr 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 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.
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.
•
•
Join Date: Feb 2007
Location: Bangalore, India
Posts: 535
Reputation:
Rep Power: 4
Solved Threads: 50
Read this.
This is what I'll tell you..
This is what I'll tell you..
bash Syntax (Toggle Plain Text)
#!/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
Last edited by thekashyap : Apr 16th, 2007 at 9:39 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Sending email from a shell script (Shell Scripting)
- Problem with variables in Windows shell script (Windows NT / 2000 / XP / 2003)
- Using find in a bash shell script (Shell Scripting)
- Shell Script for Gnome 2.6 Print Manager. (Shell Scripting)
- How to su properly in a shell script (Shell Scripting)
Other Threads in the Shell Scripting Forum
- Previous Thread: How to insert new argument into the middle of a file
- Next Thread: Need help in Shell script


Linear Mode