I have a shell script where it processes a set of files from a particular directory (shared location among 4 servers). i.e. under this directory /shared/work/ I have a set of files that needs to be processed. Since the number of files are alot, I have this script to be run from 4 servers.
So basically, when I run the script from first server, it goes thru the files in that directory and picks up one and processed it and rename the file, so the thread from the other server don't pick it up. I am using the following command to loop thru the files:
So, I have this script on all 4 servers. Theoritically it should work. However, it doesn't. Because, the value of $file, in my for loop isn't dynamic. It just reads it at the beginning, and keeps that value. So, if another thread from server 2, picks up a file and rename it, the thread from the other servers wouldn't know if the file was renamed, since $file will contain the values that initially was loaded.
So, is there an alternate way to read files from a particular directory, but dynamically--in other words, even if during the script execution, a file is renamed, it should refelect (be known) to my script.
I have a directory with the files,
1st: I want to Diplay each filename, underline it
2nd: Display the contents under the filename and
3rd: Redirect the above content to other file
4th: Remove the files from the directory
#!/bin/ksh
for i in $( cat $a/b/c.txt )
do
echo "... (1 Reply)
Hi All,
I am coding for a requirement where I need to read a file & get the values of SUB_DATE. Once the dates are found, i need to move the files based on these dates from one directory to another.
ie, this is how it will be in the file,
SUB_DATE = 20120608,20120607,20120606,20120606... (5 Replies)
Hi ,
I have searched through the forum but not able to find out any help :(
i have a directory having lot of files which contains sql statemtns
eg : file 1 contains
select from table_name1 where .....................
select from
table_name2 where ..........
select
from ... (3 Replies)
Hi All,
Request your expertise in tackling one requirement in my project,(i dont have much expertise in Shell Scripting). The requirement is as below,
1) We store the last run date of a process in a file. When the batch run the next time, it should read this file, get the last run date from... (1 Reply)
Hi all,
I'm very, very new to scripting (let alone SHELL) and was wondering if anyone could help me out as I seem to be in a spot of bother.
I collect data (.dat files) which are automatically seperated into several sub directories, so the file paths I'm reading in at the moment would be... (11 Replies)
Can some body help me to code this?
go to a specific directory.(/home/abcd/test)
file1.txt,
file2.txt,
...
..
filen.txt
read the files in side the folder 'test' and print the content of each file into other folder in the same directory lets say(testresult) with the same file name... (4 Replies)
I am trying to make a simple script where you type in a directory, and the script tells you how many directories are within the directory, how many files, and some other general file information. My problem is setting up a for loop to read the info about the files inside the specified directory.... (2 Replies)
Hi
I'm trying to call my files from different directories in my script.
Can you please help me.
Here is my script:
#!/bin/bash
#----------------------------------------------------------------------------------------------------------------------
#This script allows the user... (1 Reply)
Hi Everyone , have a nice day
i need a help on this thing
algo is something like
in certain path like /root/user1
i have many files , i need a code which could open every file one by one and then
each file has contents like this
<moid>CcnCounters=CAPv3-Received-Total-Requests, Source =... (3 Replies)