sed and awk Commandlist

sed -e :a -e 's/<[^>]*>//g;/</n;//ba'
(Entfernt Html)´

sed -e s/Stop.*$//
(Löscht Alles Nach Stop)

sed q
(Ausgabe Erste Zeile)

sed 's/[ \t]*$//'
Lösche Unsichtbare Zeichen (Leerzeichen, Tabulatoren) Vom Ende Aller Zeilen

sed 's/^[ \t]*//;s/[ \t]*$//'
Lösche Unsichtbare Zeichen Sowohl Am Anfang Als Auch Am Ende Jeder Zeile

sed '1d'
(Lösche Erste Zeile)

sed '$d'
(Lösche Letzte Zeile)

head -n -5
(löscht 5 letzten Zeilen)

sed 'n;n;s/\n/ /g'
(Fügt Drei Zeilen Die Untereinander Stehen Zusammen, Mit Leerzeichen)

sed '/pics[/]pix.gif/s/^/notRepl:
(fügt notRepl direkt an Anfang der Zeile hinzu wenn pic/pix.gif enthalten ist in der Zeile)

sed s/^.*http/http/
How Do You Delete The Text At The Beginning Of Every Line Until A Certain Word Using Sed?

sed -n '/Word1/,/Word2/p' File
(Gebe Alles Zwischen Word1 Und Word2 Aus)

grep -c Word File
(Zählt Wie Oft Das Wort Vorkommt)

tr -d '\015\032'
(Entfernt \n \t)

sed -e "/^ *$/d"
(Löscht Leerzeilen Aus Datei)

sed -e "s/[']&nbsp;//g"
(entfernt Ä&bnsp; am anfang)

sed 's/&nbsp;//g'
(entfernt &bnsp; am anfang)

echo -n
(ohne \n)

#! /bin/sh
test=2
test2='loginName='$test'&pass=
echo $test2
(Variable)

./wkw.sh loginname passwort
-d 'loginName='$1'&pass='$2'&x=0&y=0&logIn=1'
(Übergabe)

#! /bin/sh
if test -f tmp_sg_test > 0
then
echo "yes"
else
echo "no"
fi
(Existiert Datei?)

sed -e 's/[\]//'
(lösche \ am Ende)

sort
(sortiert)

uniq
(wenn sortiert alle zeilen untereinander löscht es doppelte zeilen)

grep
(-A anzahl zeilen nach match, -B anzahl zeilen bevor match)

sed -e 's/<\/a><\/li><li>/test/g'
(</a></li><li>)

var1=$(echo $1 | sed s/@/%40/g)
(wandelt $1 email in unicode um in $var1)

| sed s/ä/ä/g | sed s/ö/ö/g | sed s/ü/ü/g
(ä und ö und ü ändern)

#! /bin/sh
while [ "$1" ]; do
echo "$1"
shift
done
( parameterübergabe ans skript: ein parameter nach dem nächsten abarbeiten)

date '+%y/%m/%d %H:%M:%S'
(Ausgabe Jahr, Monat, Tag, Stunde, Minute, Sekunde)

test.sh
#! /bin/sh
. config.var
name=animexx
echo $tmp$name
tmp=$tmp$name
echo $tmp
echo $client

config.var
tmp=./tmp/tmp_
client='"Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)"'
( config file mit zentralen parametern aus config.var )

VARIABLE=`date +"%y%m%d"`
Die ` sind Backticks, also Umschalt+Taste neben Backspace auf einer deutschen Tastatur.
Einfacher zu lesen und zu schreiben ist die $() Variante: VARIABLE=$(date +"%y%m%d")

while read line
do
echo $line
done < mydatafile
(read file line by line and DO echo them)

sed -e 's/.\{7\}$//'
( letzten 7 zeichen loeschen )

Eisfair Configuration

Service List to Install \ Configure:

Inet Service: SSH Port
Certs Service: -
Apache2 Webserver: Web Port, Log Settings
MySQL Server: Mysql Port, Log Settings, Network Enable, Cache Sizes
Squid proxy: Cache off
Minicom Service: -
LPRng: -
Samba: Create Users and Configure Shares and Network
Dyndns: Configure DynDns Services
MINI_HTTPD: Port, SSL, Special Configuration
Netdate Service: Configure NTP Server
teamspeak: Configure superadmin, admin
streamripper: -
RSYNC: Configure Backup Shares and User
Power Button: -

Firewall:
/etc/hosts.allow
---------------------------------
#----------------------------------------------------------------------
# /etc/hosts.allow file generated by '/tmp/install.sh'
#
# Creation date:  10.02.2005  root
#
# Do not edit this file directly, create a '/etc/hosts.allow.package-name'
# file and re-run the 'update-hosts.allow' command to update.
#----------------------------------------------------------------------

ALL:ALL

Ramdisk:

/etc/init.d/ramdisk

#! /bin/sh
#----------------------------------------------------------------------------
# /etc/init.d/ramdisk - ramdisk secrets.tdb            vscan-fprotd.conf
#roup.old       mib.txt         secrets.tdb.samba.bak  vscan-fsav.conf
# Creation:     19.07.2003  fm  securetty              vscan-icap.conf
# Last Update:  20.07.2003  fm  security               vscan-oav.conf
#osts.allow     motd            services               vscan-sophos.conf
# Copyright (c) 2003 Frank Meyer <frank@eisfair.org>   vscan-trend.conf
#ttpd           mtools.conf     shadow                 wgetrc
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#----------------------------------------------------------------------------

case $1
in
start)
/bin/mount -t ramfs log /var/log -o maxsize=2000
/bin/mount -t ramfs www-log /var/www/log -o maxsize=2000
#/bin/mount -t ramfs none /var/squid/log -o maxsize=2000
# modprobe usb-storage   >/dev/null 2>&1
# insmod sd_mod          >/dev/null 2>&1
# insmod usb-uhci        >/dev/null 2>&1
# insmod usb-ohci        >/dev/null 2>&1
;;
stop)
umount /var/log
umount /var/www/log
#umount /var/squid/log
;;
esac

chmod +x

SymLinks in /etc/rc2.d/K37ramdisk, S37ramdisk

Local

/etc/init.d/local

#! /bin/sh
#----------------------------------------------------------------------------
# /etc/init.d/local - rc script for gerneral purpose
#
# Creation:     19.07.2003  fm
# Last Update:  20.07.2003  fm
#
# Copyright (c) 2003 Frank Meyer <frank@eisfair.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#----------------------------------------------------------------------------

case $1
in
start)
# mount /dev/hdc /hdd -t ext3
# hdparm -d1 /dev/hdc # DMA an
# hdparm -S 30 /dev/hdc # Spindown
# hdparm -y /dev/hdc # Sofort Spindown

#/pvpgn/sbin/bnetd
;;

stop)
# umount /hdd

#killall bnetd
ethtool -s eth0 wol g
;;
esac

Base, Special User:

 vi /home/USER/.profile
 exec /bin/bash -r

 vi /home/USER/.bashrc
 alias bash='echo "syntax error"'
 alias unalias='echo "ooh, arent you a clever boy!"'
 alias alias='echo "nice try"'

HTTPD:

1.  /etc/httpd/mini_httpd.conf
pidfile=/var/run/mini_httpd_base.pid
pidfile=/var/run/mini_httpd.pid

2.  vi /etc/adminlog.conf
Inhalt: *.* /var/log/log.admin
3.  vi /usr/local/htdocs/adminlog.cgi mit Inhalt
#!/bin/sh
#------------------------------------------------------------------------------
# syslog.cgi - show the syslog-file
#
# Creation: 28.10.2003 mgh
# LU : 02.08.2004 opi
#
# 02.08.04 add missing end tags on error exits
#
#------------------------------------------------------------------------------

SEC_REALM='logs'
SEC_ACTION='view'

. sec-lib.cgi

# Parse variables...
eval "`proccgi $*`"

echo "Content-Type: text/html; charset=iso-8859-1"
echo "Cache-control: no-store" # HTTP/1.1 (or no-cache?)
echo "Pragma: no-cache" # HTTP/1.0
echo "Expires: `date -Ru`" # Expires now!
echo
echo '<html><head>'
echo '<LINK REL=STYLESHEET TYPE="text/css" HREF="main.css">'
echo '<title>Syslog</title>'
echo '</head><body bgcolor="#FFFFFF" text="#000000">'

if [ ! -f /etc/adminlog.conf ]
then
echo "<h1>Error</h1><p>Keine /etc/adminlog.conf
vorhanden!</p></body></html>"
exit 1
fi

set -f # disable pathname expansion
if [ "$FORM_target" = "" ]
then
FORM_target='*.*'
fi

while read a b
do
if [ "$FORM_target" = "$a" -a -f "$b" ]
then
printout=$b
fi
done < /etc/adminlog.conf
set +f

if [ "$printout" = "" ]
then
echo "<h1>Fehler</h1><p>Keine Datei des Adminlog-Ziels $FORM_target
gefunden!</p></body></html>"
exit 1
fi

echo "<h1>Adminlog</h1><p>Datei: $printout ($FORM_target)<pre>"
sed '1!G;h;$!d' $printout
echo '</pre></body></html>'

exit 0

4. Es wird in der Datei /etc/httpd/menu unter
e sr.cgi Serverswitch
eine zusätzliche Zeile
e serverswitch.cgi Serverswitch
angelegt (die ins Leere zeigt).

5. mini_http Port 81

Eisfair von ESXi auf CF

- ESXi Export für Workstation / Player
- Erweitere Template mit VMXBuilder um IDE Festplatte, size minimum the SCSI HDD
(Vorsicht, IDE:0:0!, CD Laufwerk auf IDE:0:1 setzen!)
- Booted VM mit "Ultimate Boot CD", starte Tool "g4u" V1.17
- Kopiere SCSI Disk auf IDE Disk
- Editiere Template: Entferne SCSI HDD
- Boote mit "Ultimate Boot CD", DamnSmall Linux
- mount /dev/hda2
- sudo vi /etc/fstab: /dev/sda1 und /dev/sda2 auf /dev/hda1 und /dev/hda2 ändern
- umount
- boot

Bootloader
---------------------------------
---------------------------------

/etc/lilo.conf
---------------------------------
disk = /dev/hda
bios = 0x80
boot = /dev/hda
read-only
prompt
timeout = 50
vga = normal
image = /boot/kernel
root = /dev/hda2
label = eis
initrd = /boot/initrd.gz
append = "ide=nodma acpi=force"
---------------------------------

Anschließend "lilo -v"

- wenn Eisfair läuft, neustarten
- Boot auf CD Image Acronis Home
- Image erstellen und auf Netzlaufwerk speichern

Am neuen PC
- Installiere Eisfair auf dem neuen Datenträger / CF
- wenn Eisfair läuft, neustarten
- Boot auf CD Image Acronis Home
- Image von hda2 aus dem Netzlaufwerk wiederherstellen
- booten
- Anschließend "lilo -v"

fertig