Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-11-2002, 01:47 PM   #1
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

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 02:28 PM.
Old 11-12-2002, 01:33 PM   #2
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, 10:05 PM   #3
LQ Newbie
Registered: Nov 2002
Location: Boston, MA
Distribution: 6.2 7.0 8.0
Posts: 2

Original Poster
Rep: Reputation: 0

Unfortunately it did not add dot gz. It just added the letters gz on the end of every filename it could. 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, 06:04 AM   #4
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982
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...

for i in *
  mv $i `echo $i | sed s/.gz$//`

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


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 03:40 AM
script #!/bin/bash, problem with space in file names existent Linux - General 3 06-17-2004 08:13 AM
Expanding file names in a script? ../blah -> /home/blah Bebo Linux - General 24 03-29-2004 05:39 PM
Trimming a file james_cwy Linux - Newbie 4 01-13-2004 10: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 02:13 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:45 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration