Warning: require() [function.require]: open_basedir restriction in effect. File(/usr/local/php-spez-5.2.17/lib/php/geshi/geshi.php) is not within the allowed path(s): (/usr/local/php/lib/php/:/home/www/:/usr/bin/:/tmp:/usr/local/php52/lib/php/) in /home/www/web25/html/syswiki/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php on line 376
Bash tips – HS Syswiki

Bash tips

Aus HS Syswiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „<syntaxhighlight lang="bash" style="font-size:9pt;"> # bash history without numbers history | cut -c 8- history | cut -d' ' -f4- | sed 's/^ \(.*$\)/\1/g' </syn…“)
 
Zeile 3: Zeile 3:
 
history | cut -c 8-
 
history | cut -c 8-
 
history | cut -d' ' -f4- | sed 's/^ \(.*$\)/\1/g'
 
history | cut -d' ' -f4- | sed 's/^ \(.*$\)/\1/g'
 +
</syntaxhighlight>
 +
 +
== SED ==
 +
<syntaxhighlight lang="bash" style="font-size:9pt;">
 +
# Insert string to configuration file
 +
# To append after the pattern: (-i is for inplace replace). line1 and line2 are the lines you want to append(or prepend):
 +
 +
sed -i '/pattern/a \
 +
line1 \
 +
line2' inputfile
 +
 +
# To prepend the lines before:
 +
 +
sed -i '/pattern/i \
 +
line1 \
 +
line2' inputfile
 +
 +
# Find all SSL CA activators and change string from apache to apache2
 +
find /home/broot/ -name "*SSL_CA_activator.sh" -type f -exec sed -i 's/\/apache\//\/apache2\//g' {} ";" -exec sed -i 's/\\\/apache\\\//\\\/apache2\\\//g' {} ";" -exec sed -i 's/\/etc\/rc.d\/apache restart/\/etc\/rc.d\/apache2 restart/g' {} ";"
 +
 +
# Finding with DSSH
 +
dssh "find /home/broot/ -name \"*SSL_CA_activator.sh\" -type f -exec ls -la {} \";\"" | less
 +
 +
# Path correction in httpd.conf file
 +
dssh "sed -i \"s/\/usr\/local\/apache2\/icons/\/usr\/local\/apache2\/share\/icons/g\" /usr/local/apache2/conf/httpd.conf"
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Server]]
 
[[Category:Server]]

Version vom 17. Juni 2014, 16:08 Uhr

# bash history without numbers
history | cut -c 8-
history | cut -d' ' -f4- | sed 's/^ \(.*$\)/\1/g'

SED

# Insert string to configuration file
# To append after the pattern: (-i is for inplace replace). line1 and line2 are the lines you want to append(or prepend):
 
sed -i '/pattern/a \
line1 \
line2' inputfile
 
# To prepend the lines before:
 
sed -i '/pattern/i \
line1 \
line2' inputfile
 
# Find all SSL CA activators and change string from apache to apache2
find /home/broot/ -name "*SSL_CA_activator.sh" -type f -exec sed -i 's/\/apache\//\/apache2\//g' {} ";" -exec sed -i 's/\\\/apache\\\//\\\/apache2\\\//g' {} ";" -exec sed -i 's/\/etc\/rc.d\/apache restart/\/etc\/rc.d\/apache2 restart/g' {} ";"
 
# Finding with DSSH
dssh "find /home/broot/ -name \"*SSL_CA_activator.sh\" -type f -exec ls -la {} \";\"" | less
 
# Path correction in httpd.conf file
dssh "sed -i \"s/\/usr\/local\/apache2\/icons/\/usr\/local\/apache2\/share\/icons/g\" /usr/local/apache2/conf/httpd.conf"
Meine Werkzeuge
Namensräume

Varianten
Aktionen
Navigation
Werkzeuge