Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 02-04-2013, 04:51 AM   #1
LQ Newbie
Registered: Aug 2012
Posts: 14

Rep: Reputation: Disabled
Remove space from a zip file

Hi Team,

I have an requirment from functional pepole they have some zip file & want to unzip this file & thn remove space from tge file name & than zip this file again.
For Example:- I have file name like "T002" Now i ahve to perform below steps
1:- unzip this file "T002" (Unzip T002

As per me unix take ot two diffrent nae & can't unzip this file
2:- After unzip we get file "T002 20130131"
now we have to remove the space between "T002" & "20130131" . The output should be "T00220130131"
3:- Now again zip this file "" & copy to a specfic location.

Is this possible in Linux?
Old 02-04-2013, 05:55 AM   #2
Senior Member
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Debian, Arch
Posts: 1,163
Blog Entries: 7

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Found this snippet on the web that may help you (credit:

- unzip the file into a directory, say ~/tmp (replace ~/tmp with the directory you unzipped to)

- find ~/tmp -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;

- zip the files back up
Even though that expression in the find command is looking for a filename with one space, it will replace all spaces in filenames. If you don't want an underscore to replace the space, replace it with what character (or nothing at all) you want.

If you have several such files, you could write yourself a shell script to make it faster and easier.

Last edited by goumba; 02-04-2013 at 05:59 AM.
1 members found this post helpful.
Old 02-04-2013, 06:24 AM   #3
Senior Member
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Which distro you're using? For linux based distro you can find rename command.
~$ rename 's/ //' T002\
~$ ls -la T002*
Tip: Use tab key after typing first 2 or 3 letters of a filename, so shell will automatically take full filename and for space characcter it will automatically add a backslash before it to avoid interpreting special characters.

And how many files you've? For more files you can create a script like:-
echo -n "Enter filename: "; read oldname
newname=$(echo $oldname | tr -d ' ')
mv "$oldname" $newname
echo "Done for file $oldname"

Last edited by shivaa; 02-04-2013 at 06:27 AM.
1 members found this post helpful.
Old 02-04-2013, 06:11 PM   #4
Registered: Mar 2008
Posts: 17,000

Rep: Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513
At one time it was an option of the zip program to be able to edit the embedded file names. Not sure it that was ever in linux.


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
[SOLVED] Move file names with space to other directory with different file name with space pradeepdee6 Linux - Newbie 9 08-08-2012 09:19 AM
How to find out a file in a WAR which in a zip without unzip the zip-file? thomas2004ch Linux - Software 3 09-30-2011 03:06 PM
Shell Script how to remove absolute paths from zip archive hi_irf Linux - Newbie 1 10-03-2009 05:59 AM
how to remove a directory name with space ? jimmyjiang Red Hat 3 03-17-2008 10:46 AM
create a self-extracting zip file with zip on solaris? samsolaris Solaris / OpenSolaris 3 10-15-2004 01:50 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:27 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration