Difference between revisions of "Divers"

From Hugo Villeneuve
Jump to: navigation, search
Line 3: Line 3:
   
 
'''Pour capturer les données sur le réseau:'''
 
'''Pour capturer les données sur le réseau:'''
tcpdump -X -n -t -s 0 src 192.168.0.45
+
<nowiki>tcpdump -X -n -t -s 0 src 192.168.0.45</nowiki>
   
 
'''Pour afficher une image en arrière-plan (X-Windows):'''
 
'''Pour afficher une image en arrière-plan (X-Windows):'''
wmsetbg --center --workspace 0 image.jpeg
+
<nowiki>wmsetbg --center --workspace 0 image.jpeg</nowiki>
   
 
'''Configuration du naviguateur dans Sylpheed'''
 
'''Configuration du naviguateur dans Sylpheed'''
opera -newpage %s
+
<nowiki>opera -newpage %s</nowiki>
   
 
'''Configuration du client Email dans Opera'''
 
'''Configuration du client Email dans Opera'''
Line 17: Line 17:
 
 
 
You could use find and sed, but I find that this little line of perl works nicely:
 
You could use find and sed, but I find that this little line of perl works nicely:
perl -pi -w -e 's/search/replace/g;' *.php
+
<nowiki>perl -pi -w -e 's/search/replace/g;' *.php</nowiki>
   
 
-e means execute the following line of code.
 
-e means execute the following line of code.
Line 25: Line 25:
   
 
Example I had the following style sheet in a section:
 
Example I had the following style sheet in a section:
<link rel="stylesheet" type="text/css" href="../includes/style.css">
+
<nowiki><link rel="stylesheet" type="text/css" href="../includes/style.css"></nowiki>
   
 
and I wanted the following instead:
 
and I wanted the following instead:
<link rel="stylesheet" type="text/css" href="admin.css">
+
<nowiki><link rel="stylesheet" type="text/css" href="admin.css"></nowiki>
   
 
As each expression is a regular expression you've got to escape the special characters such as forward slash and .
 
As each expression is a regular expression you've got to escape the special characters such as forward slash and .
\.\.\/includes\/style\.css
+
<nowiki>\.\.\/includes\/style\.css</nowiki>
   
 
So the final line of code ends up as
 
So the final line of code ends up as
perl -pi -w -e 's/\.\.\/includes\/style\.css/admin\.css/g;' *.php
+
<nowiki>perl -pi -w -e 's/\.\.\/includes\/style\.css/admin\.css/g;' *.php</nowiki>

Revision as of 20:55, 5 March 2008

Divers

Pour capturer les données sur le réseau:

 tcpdump -X -n -t -s 0 src 192.168.0.45

Pour afficher une image en arrière-plan (X-Windows):

 wmsetbg --center --workspace 0 image.jpeg

Configuration du naviguateur dans Sylpheed

 opera -newpage %s

Configuration du client Email dans Opera

  sylpheed --compose [mailto:%t][?subject=%s]

How to do a search and replace over multiple files?

You could use find and sed, but I find that this little line of perl works nicely:

   perl -pi -w -e 's/search/replace/g;' *.php 
 -e means execute the following line of code.
 -i means edit in-place
 -w write warnings
 -p loop

Example I had the following style sheet in a section:

 <link rel="stylesheet" type="text/css" href="../includes/style.css">

and I wanted the following instead:

 <link rel="stylesheet" type="text/css" href="admin.css">

As each expression is a regular expression you've got to escape the special characters such as forward slash and .

 \.\.\/includes\/style\.css

So the final line of code ends up as

 perl -pi -w -e 's/\.\.\/includes\/style\.css/admin\.css/g;' *.php