How to Change the Content Files Simultaneously In Website

How to Change the Content Files Simultaneously In Website
Often create a file that uses the word / phrase repeated? In many file / files? And often have to be changed? If yes, please continue to the bottom. If not? Please see the tutorial below.

Examples of cases. Denis is making a simple site that consists of 4 pages:

     home.html to be used as a porch.
     profil.html which contains profiles of companies and others.
     kontak.html, providing relevant contacts and addresses.
     tentang.html, contains an explanation of the history of the establishment, and about his company.

Display the page as shown below:
home_page

User Commands (‘sed’ dan ‘grep')
Well, after so, it turns out the files there is something wrong. In the footer (copyright). The phrase "copyright © ts @ 2011" the truth is: "Copyright © 2011 Denis".

Want to change all that by opening sentence tiap2 file, the Denis lazy. He thinks there should be way more practical. Because, how kaloberkas / files are made ​​not only 4, but 24? Mabok, comrade! Incidentally he was using the Ubuntu linux and hear-hear there is a command that can do that, the command "sed" or joint command "grep + sed". What about Windows users? Unfortunately, it is not possible except windowsnya to install the program 'sed' and 'grep', which would be quite troublesome.
Manual 'sed' and 'grep'
After a long and exhaustive search (Denis version), he gets to do it. Example code is:

# Sed-i 's / word or phrase that you want to change / word you want to use / g' nama_berkas
# Grep-i sed 's / word or phrase that you want to change / word you want to use / g' nama_berkas

And he was then practicing them into files that he created it, becomes:

# Sed-i 's / copyright \ © ts @ 2011 / \ © 2011 Denis / g' *. html
# Grep-rl "copyright \ © ts @ 2011". | Xargs sed-i 's / copyright \ © ts @ 2011 / \ © 2011 Denis / g'
pwd (the directory where we are) and the ls-l (show all files)
pwd (the directory where we are) and the ls-l (show all files)
Home.html+code+before+changing+it
 Home.html code before changing it.
Home.html+code+after+the+code+above+typed
Home.html code after the code above typed. 
Home.html+code+after+the+change+occurs
 Home.html code after the change occurs.

Explanation of code:

1.    Attention! Quotation marks are used in the explanation of the code just to clarify its code. If you want to type the command (example: 'sed'), do not include quotation marks only.
2.    'Sed-i' means that the command 'sed' will change the contents of the file tersebu. If it does not give the '-i', 'sed' will only display the changes that occur in the terminal, while the file remains intact. Example: if you want to change the contents of the file home.html, the changes will only be displayed on the terminal. The contents of the file home.html its own will not change.
3.    'S / copyright \ © ts @ 2011 / \ © 2011 Budi / g'. The '/' to separate command and word / phrase you want to change. It could also be replaced with other punctuation marks, such as '|' or '#' and so forth. 'S' in front means substitute (replace). And 'g', a global, does it mean to do repeatedly on each word / phrase you want to change it. To mark '\' in front of the sign read '&', the '\' is used because the sign read '&' is included command 'sed'. Therefore need to be given the '\' to mean what it is. If you only want to change the numbers / words alone, it is usually not as difficult as this, should give the '\' in certain places.
4.    '*. Html' means to change all the files have the extension. Html (In the example case above, all of the file). If you want to change all files regardless of extension, can directly use the sign '*'.
5.    'Grep-rl "copyright © ts @ 2011".' Means to take (grep) all files in this directory and its sub-directory (.) Containing the text 'copyright © TS @ 2011'. Do a search and display the file name berulang-ulang/recursive / her file (-rl).
6.    '|' Is a pipeline. In Linux, we can combine the use of more than 2 orders. The trick, is using the pipeline. In this case, the combined command is' grep'untuk search for all files in a directory and its sub-directories and 'sed' to change the contents of his file.
7.    'Xargs' will run the command by receiving input from standard input (stdio), in this case is the output of 'grep', and then forwarded to the command behind the word 'xargs' is. For more details, could try running the command 'grep-rl "copyright \ © ts @ 2011".' Well, this output will be processed by the 'xargs''to be forwarded to the command' sed-i 's / copyright \ © ; ts @ 2011 / \ © 2011 Budi / g '


Examples of the use of the 'sed' and 'grep' in just a few of what can be done by both the command. By using the command 'sed', we can change all the numbers in one / more of the files to be what we want, for example. And by 'grep', we can search for words / phrases / numbers / symbols etc. with certain patterns. How so? Everything can be done because of the role of the Regular Expression in the second command. How to Change the Content Files Simultaneously In Website in Linux. cool is not it?

 
Free Host | new york lasik surgery | cpa website design