LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-11-2002, 02:47 PM   #1
eagletech
LQ Newbie
 
Registered: Nov 2002
Location: Boston, MA
Distribution: 6.2 7.0 8.0
Posts: 2

Rep: Reputation: 0
Post Desperate!!Help with a Script for Batch Trimming last 2 letters of file names


Hi,
I am fairly new to Linux other than a user. I was trying to Gzip a directory with gzip -rvf -S gz /usr/local/Zope ...
It added gz to every filename in this and all subdirectories. I have been poking around for 2 hours to find a script to trim the gz off the file names. Could anyone help me with a script and give me the correct syntax to zip that directory so I can download it to my linux box at home and play with it.

Thanks in Advance... I am freaking out here. My system admin is on vacation for 2 weeks.

Last edited by eagletech; 11-11-2002 at 03:28 PM.
 
Old 11-12-2002, 02:33 PM   #2
Smitty-rh
Member
 
Registered: Oct 2002
Distribution: Redhat
Posts: 35

Rep: Reputation: 15
first, I am guessing that when you say it added gz to the end of each file that it added .gz ??

If so then each file is simply the gzipped version of the original. to get rid of the gz, or uncompress them because that is what you are really doing, you will need to use gunzip to uncompress them.

I assume also that what you want to do is put the directory in one file and download it. To do that I recommend you use tar to put all that directory into one archive and then use gzip to compress the archive.

make sure you read the man pages for tar and gzip before you try this.

good luck
 
Old 11-12-2002, 11:05 PM   #3
eagletech
LQ Newbie
 
Registered: Nov 2002
Location: Boston, MA
Distribution: 6.2 7.0 8.0
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks

Unfortunately it did not add dot gz. It just added the letters gz on the end of every filename it could.

foo.bar became foo.bargz

My ISP ,where I pay big money to co-locate my box. stopped backing me up 2 years ago when they changed their backup system and I fell through the cracks so I cannot restore.

I looked at some files and it also changed some of the english to gibberish. Not allthough. I'm limping along having changed many files back by hand.
 
Old 11-13-2002, 07:04 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
are you REALLY REALLY sure that that is what's happened? run "file afilethathaschanged" to ensure that they aren't actually gzip files. if that's what has happened, and i think it is possbile, as gzip can do some bizarre things, just use a script like...

Code:
for i in *
do
  mv $i `echo $i | sed s/.gz$//`
done

Last edited by acid_kewpie; 11-13-2002 at 07:07 AM.
 
  


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
bash:output file names from shell script to vi sickboy Linux - Newbie 6 10-14-2004 04:40 AM
script #!/bin/bash, problem with space in file names existent Linux - General 3 06-17-2004 09:13 AM
Expanding file names in a script? ../blah -> /home/blah Bebo Linux - General 24 03-29-2004 06:39 PM
Trimming a file james_cwy Linux - Newbie 4 01-13-2004 11:08 PM
a script that go read the users names in a file and automaticly add then with a commo tumemanques211 Programming 2 03-22-2002 03:13 PM


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