Replace white spaces of multiple files at once


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace white spaces of multiple files at once
# 1  
Old 11-12-2012
Replace white spaces of multiple files at once

How to rename multiple files by replacing the white spaces with underscore

for ex:

Code:
293TrexFH\ \ \ GSM855007RINGB_lhb11_binary.txt
293TrexFH\ \ \ GSM855007RINGB_lhb12_binary.txt
293TrexFH\ \ \ GSM855007RINGB_lhb13_binary.txt


Code:
293TrexFH_GSM855007RINGB_lhb11_binary.txt
293TrexFH_GSM855007RINGB_lhb12_binary.txt
293TrexFH_GSM855007RINGB_lhb13_binary.txt


thanx in advance
# 2  
Old 11-12-2012
Code:
cat input_file | tr -s ' ' '_' > output_file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk gsub command to replace multiple spaces

Hi Forum. I'm trying to cleanup the following data elements (To remove any occurences of commas and any extra spaces) while preserving the <TAB> delimiter using awk gsub but I have not been successful. Original Data: 4365 monte des source rue,, ,<TAB>trevost<TAB>QC Desired Data:... (1 Reply)
Discussion started by: pchang
1 Replies

2. Shell Programming and Scripting

List and Delete Files which are older than 7 days, but have white spaces in file name

I need to list and delete all files in current older which are olderthan 7 days. But my file names have white spaces. Before deleting I want to list all the files, so that I can verify.find . -type f -mtime +7 | xargs ls -l {} But the ls command is the working on the files which have white... (16 Replies)
Discussion started by: karumudi7
16 Replies

3. Shell Programming and Scripting

How to ignore white spaces while comparing two files.?

Hello Experts, I am trying to compare two files line by line with below code. I want to ignore the spaces while comparing. Only content should be compared. hostFile="/etc/hosts" inputFile="/home/scripts/DR/hosts.eas" grep -E '^{1,3}\.{1,3}\.{1,3}\.{1,3}' $inputFile > temp1... (9 Replies)
Discussion started by: sharsour
9 Replies

4. AIX

Replace all TAB characters with white spaces

Dear Gurus Can you please advise me on how to Replace all TAB characters with white spaces in a text file in AIX? Either using vi or any utilities (2 Replies)
Discussion started by: tenderfoot
2 Replies

5. Shell Programming and Scripting

How to Use Sed Command to replace white spaces with comma from between two fields - Mayank

SHELL SCRIPT Hi I have a file in the following format Mayank Sushant Dheeraj Kunal ARUN Samir How can i replace the white space in between and replace them with a comma?? The resultant output should be Mayank,Sushant Dheeraj,Kunal ARUN,Samir i tried using sed -e... (8 Replies)
Discussion started by: mayanksargoch
8 Replies

6. Shell Programming and Scripting

Replace multiple dots (.) with spaces ( )

Hi all, I have files in the filename pattern of, this.is.the.name.of.my.file.mov and I would like to remove dots (.) and replace them with spaces ( ) so the output would be, this is the name of my file.mov The other issue that I have is that the number of dots (.) in the file... (6 Replies)
Discussion started by: Monkey Dean
6 Replies

7. UNIX for Dummies Questions & Answers

Replace only first found white spaces with some other characters

Anybody can help me How can I replace only four first white spaces with , or any other characters aaaa 08/31/2004 08/31/2009 permanent Logical Processors in System: 64 bedad 08/16/2001 08/15/2011 permanent Logical Processors in System: 64 badnv14 05/31/2008 05/30/2013 permanent Logical... (5 Replies)
Discussion started by: pareshan
5 Replies

8. UNIX for Dummies Questions & Answers

Delete Multiple White Spaces

Hi, I have a file that has multiple spaces between characters. I want to delete or convert the multiple spaces into a single space. I think this can be done in "sed" but I only know the syntax to delete trailing or leading spaces. Can this be done with "sed" or awk? I have a file that looks... (6 Replies)
Discussion started by: eja
6 Replies

9. Shell Programming and Scripting

trimming white spaces

I have a variable that calls in a string from txt file. Problem is the string comes with an abundance of white spaces trailing it. Is there any easy way to trim the tailing white spaces off at the end? Thanks in advance. (9 Replies)
Discussion started by: briskbaby
9 Replies

10. Shell Programming and Scripting

delete white spaces

hi all... i have the next question: i have a flat file with a lot of records (lines). Each record has 10 fields, which are separated by pipe (|). My problem is what sometimes, in the first record, there are white spaces (no values, nothing) in the beginning of the record, like this: ws ws... (2 Replies)
Discussion started by: DebianJ
2 Replies
Login or Register to Ask a Question