LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-24-2005, 01:29 AM   #1
izza_azhar
LQ Newbie
 
Registered: Jan 2005
Location: malaysia
Posts: 18

Rep: Reputation: 0
how to determine the folder contain data or not


hi all,
let me clarify it :
my script actually will move the old record in each directory
example:

for folder in $DSC $LOGS $PROCESSED $BAD $PROCESSED_7B1

do

cd $folder
for FILE in *_7B1*

do
curr_year=$(date +%Y)
curr_month=$(date +%Y%m)
file_year=$(echo $FILE| cut -d'_' -f4|cut -c 1-4)

file_month=$(echo $FILE|cut -d'_' -f4|cut -c 1-6)
specific_month=$(echo $FILE|cut -d'_' -f4|cut -c 5-6)
-
.....bla..bla..
if [[ `expr $curr_year - 2 ` -ge $file_year ]]

then
echo $FILE
mv $FILE ARCHIVE
echo "file transfer complete"

fi
...bla..bla..blaa
<old file will be move to the ARCHIVE folder>

but when there is no data on that folder, there is error like this :

expr: 0402-050 Syntax error.
ARCHIVE_B2B_SCRIPT.sh[69]: test: 0403-004 Specify a parameter with this command.
*_7B1*
mv: 0653-401 Cannot rename *_7B1* to ARCHIVE/*_7B1*:
A file or directory in the path name does not exist.

can u help me to solve this?
 
Old 05-24-2005, 02:31 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try this

for FILE in `ls *_7B1*`

note that those are backquotes (`), not single quotes (').
 
Old 05-24-2005, 07:38 PM   #3
izza_azhar
LQ Newbie
 
Registered: Jan 2005
Location: malaysia
Posts: 18

Original Poster
Rep: Reputation: 0
its work

thanks...
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Folder Max Size and Limiting SSH access to home folder. Mefistofeles Linux - General 4 11-26-2005 02:09 PM
Howto determine if wireless data-layer link is up BaMbooZle64 Linux - Wireless Networking 0 02-09-2005 10:50 AM
Where is the data folder for webserver? helpme0904 Linux - General 1 11-03-2004 08:49 AM
Don't Delete This Message -- Folder Internal Data ooorah Linux - Security 2 10-18-2004 09:14 PM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration