LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-12-2011, 08:17 AM   #16
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0

Perfect. thank you.

Q1: Basename = the source name right?
Q2: Could you explain the ( meaning )compilation of "file" in these commands ?

for file in $JPG
zip -u -m /home/sok/Receive/$base.zip $file

Is file means the variable value of the source?

Last edited by MODYSAMA; 02-12-2011 at 08:29 AM.
 
Old 02-12-2011, 09:56 AM   #17
someshpr
Member
 
Registered: Jul 2009
Location: CA, USA
Distribution: Debian 7, Ubuntu 14.04
Posts: 123

Rep: Reputation: 26
Quote:
Originally Posted by MODYSAMA View Post
Perfect. thank you.

Q1: Basename = the source name right?
Q2: Could you explain the ( meaning )compilation of "file" in these commands ?

for file in $JPG
zip -u -m /home/sok/Receive/$base.zip $file

Is file means the variable value of the source?

A1: "basename" command returns the name of file/directory after stripping the suffix/extension. So if I run basename command on a file named 1.jpg as "basename 1.jpg .jpg" then it'll return 1. Do man basename for details.

A2: in the script "file", "base", and "JPG" are variables which store respectively the name of the jpg file with extension, name of the jpg file w/o extension and list of jpg files. $ denotes a variable.

Code:
for file in $JPG; do
means it'll look for any file whose name matches with the list in $JPG
Code:
base=`basename $file .jpg`
means it'll extract the name stripping the extension and store it to base
Code:
zip -m /path-to-dest/$base.zip $file
means it'll create zip from the source file ($file) and store it in destination ($base.zip)

For more explanation, read any bash scripting guides like this: http://tldp.org/LDP/abs/html/

Also, if your problem is solved, mark the thread as solved.

HTH,
 
1 members found this post helpful.
Old 02-12-2011, 09:58 AM   #18
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
someshpr
Quote:
Thank you for being helpful.
 
Old 04-19-2011, 10:28 AM   #19
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
You are right, sir.
I changed my code. It's true no need to compress a JEPG image.

I have a question.
I repleced "file" with "image" as the following:
Code:
for file in $collect;
with
Code:
for image in $collect;
But, when using file,it look as the following:

bold and coloured "file ". 1- why ?Is there different, using it instead of using any variable name?
Does it effect on the moving operation?

2- Why the size of the empty folder is 4.k (4096) not zero?

Last edited by MODYSAMA; 04-19-2011 at 10:52 AM.
 
Old 04-19-2011, 11:51 AM   #20
someshpr
Member
 
Registered: Jul 2009
Location: CA, USA
Distribution: Debian 7, Ubuntu 14.04
Posts: 123

Rep: Reputation: 26
Quote:
Originally Posted by MODYSAMA View Post
You are right, sir.
I changed my code. It's true no need to compress a JEPG image.

I have a question.
I repleced "file" with "image" as the following:
Code:
for file in $collect;
with
Code:
for image in $collect;
But, when using file,it look as the following:

bold and coloured "file ". 1- why ?Is there different, using it instead of using any variable name?
Does it effect on the moving operation?

2- Why the size of the empty folder is 4.k (4096) not zero?
1. I am not sure I understand your first question. Are you worried about the fact that color of the word "file" is same as the word "image" when you open the script in your text editor? If that is the case, no need to worry. Most text editors have a syntax-based coloring scheme and from the extension and preamble of the file they try to determine the type of the file. Based on these, the text editor colors some words differently than others. This has nothing to do with the function. So replacing "file" with "image" or any other name will not change the way the script is supposed to work.

2. As far as I know, each directory, even when they are empty, requires to store some info, such as name, permission, timestamp, etc. It therefore needs some space to store these. The size of the empty directory is the size required to store these. This size varies with file system you are using, and probably 4kb is the smallest block in your file system. So it shows up as a directory of size 4k

HTH,
 
Old 04-19-2011, 01:38 PM   #21
MODYSAMA
Member
 
Registered: Dec 2010
Posts: 144

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by someshpr View Post
1. I am not sure I understand your first question. Are you worried about the fact that color of the word "file" is same as the word "image" when you open the script in your text editor? If that is the case, no need to worry. Most text editors have a syntax-based coloring scheme and from the extension and preamble of the file they try to determine the type of the file. Based on these, the text editor colors some words differently than others. This has nothing to do with the function. So replacing "file" with "image" or any other name will not change the way the script is supposed to work.
I worried because "file"&"image" is not the same color.S I think the interpreter will different interact with "file"?! I thought
the colored thing as a defined data type.
Quote:
2. As far as I know, each directory, even when they are empty, requires to store some info, such as name, permission, timestamp, etc. It therefore needs some space to store these. The size of the empty directory is the size required to store these. This size varies with file system you are using, and probably 4kb is the smallest block in your file system. So it shows up as a directory of size 4k

HTH,
I like that analysis and now, I am well-convinced of it. I was thinking in it.And you provide me with extra details, thanks.

Last edited by MODYSAMA; 04-19-2011 at 01:41 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Zipping multiple directories Wastedsanity Linux - Newbie 3 01-16-2011 08:33 PM
zipping a directory tractng Linux - Newbie 3 04-16-2008 05:54 PM
Zipping a folder Gins Linux - General 9 06-19-2007 06:17 PM
Zipping of files rajesh_b Programming 5 10-27-2004 07:02 AM
Zipping and Taring and ? Goatdemon Linux - Newbie 3 05-22-2002 08:17 AM


All times are GMT -5. The time now is 07:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration