LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-21-2011, 10:00 PM   #1
vonshavingcream
LQ Newbie
 
Registered: Nov 2011
Posts: 1

Rep: Reputation: Disabled
looking for a space at the beginning of file contents


so i'm working a php site. about 3 days ago some image display scripts stopped working.

I discovered today that it is because a space is being output at front of every page.

I have a lot of php files since I am working in an MVC framework.

How can I check every file in the root directory and see if the first char is a space?

Code:
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
it might be hard to see above but just before the <!DOCTYPE there is space.

I have hunted for the thing for 3 hours.

any suggestions on how to find it?

Thanks,
C
 
Old 11-23-2011, 08:12 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
You can grep for it:
Code:
grep ^\ \<\!DOCTYPE *.html
or in multiple subdirs:
Code:
find "*.html" -exec grep -H ^\ \<\!DOCTYPE *.html \;
Same to find and replace:
Code:
find -name "*.html" -exec sed -i s/^\ \<\!DOCTYPE/\<\!DOCTYPE/ {} \;
Use with extreme care, sed edits the files in place. One typo and you can recreate a zillion files!

jlinkels
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting a file beginning with '?' seanybaby Linux - General 23 01-27-2010 09:57 PM
why not to show 0x100~0xfff space contents with lspci -xxxx? KoRiR Linux - Newbie 2 12-30-2007 12:29 PM
why not to show 0x100~0xfff space contents with lspci -xxxx? KoRiR Linux - Software 1 12-28-2007 03:31 AM
How to delete a file beginning with '-'? zoomzoom Linux - General 2 02-02-2004 10:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:51 AM.

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
Open Source Consulting | Domain Registration