Datei einlesen with open(filename, "w", encoding="UTF-8-sig") as f: f.write("Hallo\tWelt!") Datei schreiben with open(filename, encoding="UTF-8-sig") as f: for line in f.readlines(): animals.append(line.strip("\n"))

nawk ‚c–>0;$0~s{if(b)for(c=b+1;c>1;c–)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}‘ b=4 a=0 s="Begriff1" testfile | grep "Begriff2"
Rsync with a non-standard ssh port
Posted: 3rd August 2017 by Thorben Hemmler in ServeradministrationMit Komprimierung rsync -avz -e "ssh -p $port" user@remoteip:/path/to/files/ /local/path/ Ohne Komprimierung rsync -av -e "ssh -p $port" user@remoteip:/path/to/files/ /local/path/ Trockenlauf (Test) rsync -avn -e "ssh -p $port" user@remoteip:/path/to/files/ /local/path/
Memory gesamt svmon -G -O unit=MB | head -4 | tail -1 | awk {’print $2’} Memory in use svmon -G -O unit=MB | head -4 | tail -1 | awk {’print $3’} Free Memory svmon -G -O unit=MB | head -4 | tail -1 | awk {’print $4’} Summe XmX ps -fu $USER |grep […]
perl -le ‚use POSIX ’strftime‘; use Time::HiRes ‚gettimeofday‘; ($x,$y)=gettimeofday; $y=sprintf("%03d",$y/1000);print strftime("%Y-%m-%d %H:%M:%S",localtime($x)),".$y"‘
Linux: dmesg timestamp human readable
Posted: 30th September 2016 by Thorben Hemmler in Serveradministrationdmesg | perl -ne "BEGIN{\$a= time()- qx!cat /proc/uptime!}; s/\[\s*(\d+)\.\d+\]/localtime(\$1 + \$a)/e; print \$_;" Fri Sep 23 04:27:49 2016 sd 1:0:1:13: [sdbn] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE Fri Sep 23 04:27:49 2016 sd 1:0:1:13: [sdbn] Sense Key : Illegal Request [current] Fri Sep 23 04:27:49 2016 sd 1:0:1:13: [sdbn] Add. Sense: Illegal function (use 20 00, 24 00, […]
ls -l native_std* | awk ‚BEGIN{mega=1048576} $5 >= mega {$5 = $5/mega "MB"} {print}‘ -rw-r–r– 1 user group 31.0672MB Jun 01 15:32 native_stderr-pce.a.1.log -rw-r–r– 1 user group 41.3623MB Jun 01 15:32 native_stderr-pce.a.3.log
#!/usr/bin/perl use strict; use warnings; my @dmesg_new = (); my $dmesg = "/bin/dmesg"; my @dmesg_old = `$dmesg`; my $now = time(); my $uptime = `cat /proc/uptime | cut -d"." -f1`; my $t_now = $now – $uptime; foreach my $line ( @dmesg_old ) { chomp( $line ); if( $line =~ m/\[\s*(\d+)\.(\d+)\](.*)/i ) […]