Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Script to find and remove characters

Tags
find, linux, remove, script, shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 01-29-2008
Script to find and remove characters

Hi.

I have many files in a folder, and even more in the subfolders. I need a script that finds and removes certain characters (them being /n in this one) in the files in the folder and it's subfolders.

So, could someone write me a script that works in Linux, does this:

Searchs for "/n" in all files in the folder and it's subfolders.
Removes the "/n" from all the files

Thank you VERY much, I'm really a newbie in these things and I need this badly.
# 2  
Old 01-29-2008
You may be new, but what have you tried so far?
# 3  
Old 01-29-2008
I've been trying to google, and find the code from this forum. But, I have to say, I don't really know anything about this kind of coding, so:

I haven't really tried nothing.

I just got this task, as I'm in work atm, with "nothing better to do".

As said, if you can write me such code, I would appreciate it very much.
# 4  
Old 01-29-2008
for i in `find . -type f`
do
cat $i|tr -d '\n' > newfile
mv newfile $i
done
# 5  
Old 01-29-2008
I don't write code for people, I prefer to help them with their code, but there are many others here that will write the code for you, as pt14 has done.
# 6  
Old 01-30-2008
Quote:
Originally Posted by pt14
for i in `find . -type f`
do
cat $i|tr -d '\n' > newfile
mv newfile $i
done
beware of files with spaces. put quotes around `find....`
Also, quote your variables and forget about the cat.
Code:
...
tr -d "\n" < "$i" > newfile
...

Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Calling a find/remove within a script jeffs42885 Shell Programming and Scripting 9 05-16-2017 02:51 PM
Remove first 2 characters and last two characters of each line SkySmart Shell Programming and Scripting 5 12-19-2016 08:31 AM
Super Simple Script to remove first characters of any png file pasc Windows & DOS: Issues & Discussions 17 03-07-2013 04:44 PM
find & remove characters in filenames barrydocks UNIX for Dummies Questions & Answers 19 12-22-2011 04:05 AM
Want to remove the last characters from each row of csv using shell script rajak.net Shell Programming and Scripting 24 12-15-2011 04:54 AM
Single/Multiple Line with Special characters - Find & Replace in Unix Script r_sarnayak Shell Programming and Scripting 0 06-02-2010 02:34 AM
shell script to find noof characters in a file name krishnampkkm UNIX for Dummies Questions & Answers 10 03-10-2010 02:24 AM
How to remove Ctlr-M characters from file from a unix script akashtcs Shell Programming and Scripting 2 08-18-2009 04:11 AM
sed script to remove nth characters from end of filename Monkey Dean Shell Programming and Scripting 2 06-24-2009 01:39 AM
writing shell script to find line of invalid characters beginner82 Shell Programming and Scripting 3 06-04-2009 08:51 AM


All times are GMT -4. The time now is 10:51 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password