Categories
System/Linux/Unix*

[memo] 用 shell awk 加總 column

ls -l `find /mnt/tslog/archive/ -name “*20190[1..6]*” -type f` | awk ‘{sum += $5} END {print sum}’ 160038650315 ls -l `find /mnt/tslog_bak -name “*20190[1..6]*” -type f` | awk ‘{sum += $5} END {print sum}’ 160038650315 ls -l `find /mnt/tslog_backup2 -name “*20190[1..6]*” -type f` | awk ‘{sum += $5} END {print sum}’ 160038650315

Categories
Network service System/Linux/Unix*

ssh backup command

tar zcvf – KeepTheseFiles | ssh user@desthost ‘cat > KeepTheseFiles.tgz’

Categories
JOB Programming/C System/Linux/Unix*

get my ip address useing c / sample code

C CODE /* FILENAME : my_local_ip.c */ #include #include #include #include #include #include #include #include int main(int argc, char **argv) { int s; struct sockaddr_in sin; int slen; int port; if( argc<3 ) { printf(“Usage: %s \n”, argv[0]); printf(“\n\tsample %s 203.66.88.89 80\n”,argv[0]); return -1; } port = atoi(argv[2]); s = socket(PF_INET, SOCK_STREAM, 0); memset(&sin, 0, […]

Categories
Copy_N_Paste System/Linux/Unix*

unix shell programming / sh / csh syntax

Shell script syntax Bourne shell (sh) syntax samples test: [ number -lt|-le|-eq|-ne|-ge|-gt number ] [ string = != string ] if [ test ] then commands elif [ test ] commands else commands fi for var in item1 item2 item3 do commands done while test do commands done case expression in case1) commands ;; case2|case3) […]