LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 07: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 07:29 AM.
 
Old 02-12-2011, 08:56 AM   #17
someshpr
Member
 
Registered: Jul 2009
Location: WI, USA
Distribution: Debian 8, Ubuntu 16.04, CentOS 7
Posts: 143

Rep: Reputation: 28
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, 08: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, 09: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 09:52 AM.
 
Old 04-19-2011, 10:51 AM   #20
someshpr
Member
 
Registered: Jul 2009
Location: WI, USA
Distribution: Debian 8, Ubuntu 16.04, CentOS 7
Posts: 143

Rep: Reputation: 28
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, 12: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 12:41 PM.
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:09 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