Help with folder and file difference


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with folder and file difference
# 8  
Old 11-24-2010
Ok, so I did my studies and I maade this:

Code:
mkdir RaRai
cd Detect
while k=0
do
FILE=$(ls -rt | tail -1)
if [ -f "$FILE" ] #failas
then
   bzip2 "$FILE".bz2 "$FILE" 
   mv "$FILE" "../RaRai"
elif  [ -d "$FILE" ] #direktorija
then
   zip -r "$FILE".zip "$FILE"
   mv "$FILE".zip" ../RaRai"
   rm -r "$FILE"
fi
done

BUT after moving file to directory I get:
Code:
bzip2: Can't open input file FILE.bz2: No such file or directory.
mv: cannot stat `FILE': No such file or directory
bzip2: Can't open input file FILE.bz2.bz2: No such file or directory.
bzip2: Input file FILE.bz2 already has .bz2 suffix.

and after folder:
Code:
  adding: FOLDER/ (stored 0%)
mv: missing destination file operand after `FOLDER.zip ../RaRai'
Try `mv --help' for more information.
bzip2: Can't open input file FOLDER.zip.bz2: No such file or directory.
mv: cannot stat `FOLDER.zip': No such file or directory
bzip2: Can't open input file FOLDER.zip.bz2.bz2: No such file or directory.
bzip2: Input file FOLDER.zip.bz2 already has .bz2 suffix.

it Does the thing I need to get, but I do not need this output. How can I remove it?
# 9  
Old 11-24-2010
Your while is not optimum since you want to loop through your Detect directory:
Code:
for FILE in $(ls Detekt/*)
do
.
.

Are you sure of your bzip and zip syntax?
The fact that the shell complains is that something is wrong from shell point of vue
So showing you how to not "see" the messages is to me unproductive, if you are here it is also to learn, and learn correctly, you will see that once your shell script is done properly, no message will be issued unless something is/goes wrong ( e.g no files to process...)
read again the messages displayed and you will see the errors! (FOLDER.zip.bz2 ???)
# 10  
Old 11-24-2010
Okey. I fixed everything.

Thank you all, especially vbe for help. Honest thank you.

Last edited by juzt1s; 11-24-2010 at 01:08 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk code to find difference in second file which is not present in first file .

Hi All, I want to find difference between two files and output only lines which are not present in second file .I am using awk and I am getting only the first difference but I want to get all the lines which are not present in file2 .Below is the code I am using . Please help to get the desired... (7 Replies)
Discussion started by: srinivasrao
7 Replies

2. UNIX for Beginners Questions & Answers

UNIX utility to find difference in folder, file and contents of file against a base version

Hi, I am trying to find out whether there are any Unix utilities that compares folders, files and contents within the file and provides a comprehensive report. The comparison can be against base version of a folder and file with content. Can you please let me know of such a utility? Thanks,... (6 Replies)
Discussion started by: Sripathi_ks
6 Replies

3. Shell Programming and Scripting

How do you compare two folders and copy the difference to a third folder in a remote server?

How do you compare one local folder and a remote folder and copy the difference to a third folder in a remote folder.e.g. Folder A -- Is in a remote server and it has the following files TEST1.OUT TEST2.OUT TEST3.OUT Folder B --Is in a local server and it has the following files ... (5 Replies)
Discussion started by: cumeh1624
5 Replies

4. Shell Programming and Scripting

want to move set of file from one folder to another folder

Hi all, let me explain my requirments i am having 5 folder with different name for eg) abc , cdf , efd, rtg, ead each 5 folders contain 15 files i want to move 10 files to some other folder, remain 5 files should be there in the same folder. give me some suggestion on this. (6 Replies)
Discussion started by: natraj005
6 Replies

5. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

6. Shell Programming and Scripting

Move the file from one folder to another folder

Hi, I have a requirement to move a file from one folder(a) to another folder(b) only when folder (b) have a write permission. Folder permission is 755 If the permission is otherthan 755 we need to come out of the loop I will appreciate your help Thanks Soll (1 Reply)
Discussion started by: sollins
1 Replies

7. Shell Programming and Scripting

Calculate the time difference between a local file and a remote file.

I m stuck with a issue. I need to calculate the time difference between two files.. one on the local machine and one on the remote machine using a script. Can any one suggest the way this can be achevied Thanks, manohar (1 Reply)
Discussion started by: meetmano143
1 Replies

8. Shell Programming and Scripting

compare 2 file and print difference in the third file URG PLS

Hi I have two files in unix. I need to compare two files and print the differed lines in other file Eg file1 1111 2222 3333 file2 1111 2222 3333 4444 5555 newfile 4444 5555 Thanks In advance (3 Replies)
Discussion started by: evvander
3 Replies

9. Shell Programming and Scripting

Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies

10. UNIX for Dummies Questions & Answers

How to compare the difference between a file and a folder??

Hi, I have a .txt file which has to be compared with a folder and print the difference to some other .txt file. I did try with the diff command..i mean diff /tmp/aaa/bbb.txt /space/aaa/bbb/ /***bbb.txt contains all the files names which may or may not exist in the folder bbb..so i need... (2 Replies)
Discussion started by: kumarsaravana_s
2 Replies
Login or Register to Ask a Question