LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-05-2005, 01:23 PM   #1
Diablo81
LQ Newbie
 
Registered: Feb 2005
Posts: 5

Rep: Reputation: 0
A little script for compression :(


Hi, first of all, sorry for my poor english. I found a little script on the web, that compress some files in .tar format and I modified it a bit. Here it is:

#!/bin/bash
HLDS=/mypath/ #Working directory where demos are
REP=/mypath/ #copying directory
FORMAT=`tar -cvf`
EXTENSION=tar
#FORMAT=zip #Compression using ZIP
#EXTENSION=zip #Associated extension
cd $HLDS
for files in `ls *.dem` do
$FORMAT $files.$(date +%s).$EXTENSION $files
echo "$files.$(date +%s).$EXTENSION compressed"
mv $files.$(date +%s).$EXTENSION $REP
echo "$files.$(date +%s).$EXTENSION moved"
rm $files
echo "$files deleted"
done;
echo "Demos are available in : $REP"


The result is:

tar: option requires an argument -- f
Try `tar --help' for more information
./zipDemos: line 10: syntax error near unexpected token `$FORMAT'
./zipDemos: line 10: ` $FORMAT $files.$(date +%s).$EXTENSION $files'

I think the problem, is the argument of the command tar, but I dont understand why it doesn't work. My linux is debian. Thank you for any help!
 
Old 02-05-2005, 01:44 PM   #2
vmicho
Member
 
Registered: Jun 2003
Location: Slovakia
Distribution: Debian unstable i586
Posts: 38

Rep: Reputation: 15
the problem seem to be here:
FORMAT=`tar -cvf`

it should be
FORMAT="tar -cvf"

cuz `xxx` will execute xxx so FORMAT will contain the result of execution of xxx, not xxx


 
Old 02-05-2005, 02:57 PM   #3
Diablo81
LQ Newbie
 
Registered: Feb 2005
Posts: 5

Original Poster
Rep: Reputation: 0
thank you for reply, I will try it now ^^.
 
Old 02-05-2005, 03:01 PM   #4
Diablo81
LQ Newbie
 
Registered: Feb 2005
Posts: 5

Original Poster
Rep: Reputation: 0


it doesn't work

Now the result is:

./zipDemos: line 10: syntax error near unexpected token `$FORMAT'
./zipDemos: line 10: ` $FORMAT $files.$(date +%s).$EXTENSION $files'

Thank you anyway
 
Old 02-07-2005, 01:00 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try putting
set -xv
on the 2nd line of the script, which will show you
exactly what's going on. I ssupect you may need to say something like
${FORMAT} ${files}.$(date +%s).${EXTENSION} $files
so that the interpreter can distinguish the var names correctly.
 
Old 02-07-2005, 08:59 AM   #6
zulfilee
Member
 
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
for files in `ls *.dem` do


This line should be

for files in `ls *.dem`
do


-Do should come on the next line

Cheers
Z
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compression from rm to avi Djony Linux - Software 1 05-31-2005 11:54 AM
compression oldstinkyfish Linux - Software 2 12-02-2004 02:53 PM
best compression drigz Linux - Software 2 06-05-2004 07:38 AM
text compression mjolnir General 1 03-23-2004 02:22 PM
MPEG compression suriyamohan Programming 1 03-24-2003 06:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:22 PM.

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