Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 03-13-2003, 06:03 PM   #1
Registered: Jun 2001
Location: Chicago
Distribution: Mandrake 10.0 Official
Posts: 181

Rep: Reputation: 30
Need help with a shell script

I am teaching some students PHP and they are uploading files that they work on at home and at school. Many of these files contain a ^M character where there would normally be a UNIX line feed (in the files that I write, that is). This is making it harder for me to read their scripts.

I thought, "Well, just write a shell script to search for ^M in a file and replace all occurences with the UNIX line feed, when you supply the filename as the argument for the script." The idea seems easy enough, and I have a book on writing shell scripts which I will consult. My only problem: I don't know what character(s) or ASCII code to have the script replace the ^M with, in order to get a UNIX line feed. Do any of you?

Thanks a million!
Old 03-13-2003, 06:36 PM   #2
Registered: Jul 2002
Posts: 143

Rep: Reputation: 15
find . -name ".php" -exec perl -i -pne 's/\r\n/\n/g' {} \;
I use that when I need to pull all that crap out of a php file


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
Shell script inside shell script treotan Linux - General 4 02-19-2009 07:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-12-2005 12:08 AM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 04:00 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:23 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