LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 03-13-2003, 05:03 PM   #1
lhoff
Member
 
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, 05:36 PM   #2
turnip
Member
 
Registered: Jul 2002
Posts: 143

Rep: Reputation: 15
Code:
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
 
  


Reply


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


All times are GMT -5. The time now is 04:21 PM.

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