Change a line in a php file thanks to a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change a line in a php file thanks to a shell script
# 1  
Old 07-01-2010
Change a line in a php file thanks to a shell script

Hi,
I'm working on a script to make automatic the new releases of my website...
However in this script I put all the css script in a single one. There's no rpoblem for that.
My problem is when I want to change the header of my layout page to put instead of :
Code:
$header.="<link rel=\"stylesheet\" media=\"screen,projection\" href=\"/css/misc.css\" type=\"text/css\" />";
$header.="<link rel=\"stylesheet\" media=\"screen,projection\" href=\"/css/elements.css\" type=\"text/css\" />";
$header.="<link rel=\"stylesheet\" media=\"screen,projection\" href=\"/css/pages.css\" type=\"text/css\" />";

I want that
Code:
$header.="<link rel=\"stylesheet\" media=\"screen,projection\" href=\"/css/style.css\" type=\"text/css\" />";

I'm not really good in unix scripting but I've tried stuff like grep etc. without succeeding I'm sure it's not that hard...
Thank you for your future help
# 2  
Old 07-01-2010
Hi

Not sure, whether i understood your requirement right.


Code:
sed -n 's/misc/style/p' infile

assuming those 3 lines are present in a file, infile

Guru.
# 3  
Old 07-01-2010
Yes you got it right but I found it really hard to escape the correct things etc.
It doesn't wanna work do you know a unix function to escape a string?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script change new format on the file.

Hi---Is there's way can write small shell script or perl script open "abc.txt" file and create new "new_abc.txt" file with format output below? Thanks cat abc.txt ###########################Readme############################### Contained with this README.TXT file are all of the file... (7 Replies)
Discussion started by: dotran
7 Replies

2. Shell Programming and Scripting

Need script to change a line in file....

Hello all, I have a line of code in a file that I need to change in the /etc/sysconfig/kdump file presently the line reads: KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off" what I need to do is put a comment out the 1st line and repeat it, and... (5 Replies)
Discussion started by: gartie
5 Replies

3. Shell Programming and Scripting

Change value in a file using perl or shell script

hi, I have a local.conf file which has the first line TOPDIR = "/home/mvdev/workspace/boxer". I want to replace the value to "/home/common/workspace/mirror". I tried the following perl command that is perl -p -i -e 's/Path/path1/g' myfile.txt then sed... (7 Replies)
Discussion started by: amvarma77
7 Replies

4. Shell Programming and Scripting

shell script to change the extension of a file

I have a directory that contains several files, out of which some files are have an extra extension for example file1.new.new.new file2.new.new.new file3.new.new.new file4.new.new.new i want to write a shell script that rename all such file with only single extension like file1.new... (7 Replies)
Discussion started by: mukulverma2408
7 Replies

5. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

6. Shell Programming and Scripting

New line in shell/PHP script

hi all, I wrote a PHP script inside which am calling a shell script, In shell script, i used echo to output some results. In PHP script i just gave echo to the shell script output. But i couldn't enter the output in newline. Please help me! Thanks. PHP script <?php... (4 Replies)
Discussion started by: vidhyaS
4 Replies

7. Shell Programming and Scripting

Help with shell script for know when a file change it

Hi, IŽd like to know how to program a shell script for know when a file changes and based on that make another tasks all this in real time.. Thanks (2 Replies)
Discussion started by: mrios7
2 Replies

8. Shell Programming and Scripting

Need to change two words in a line using shell script.

Hi, i have a line tftp dgram udp wait nobody /usr/sbin/tcpd in.tftpd /tftpboott in /etc/inet.conf file. ineed to replace nobody with root and /tftpboott with /flx/boot. i tried using sed ,but i could not change both of them. can you please help me to do this. Edit:... (7 Replies)
Discussion started by: vprasads
7 Replies

9. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

10. Shell Programming and Scripting

Script to change file contents line by line

Hi, I'm struggling to write a script to do the following, -will go through each line in the file -in a specific character positions, changes the value to a new value -These character positions are fixed througout the file ----------------------- e.g.: file1.sh will have the following 3... (4 Replies)
Discussion started by: vini99
4 Replies
Login or Register to Ask a Question