Example 1: Output random String
head -c 65536 /dev/urandom | tr -dc a-zA-Z0-9 | cut -c -16
Example 2: Delete all .jpg files
find /tmp | grep .jpg$ | xargs -I@ rm @
1
echo test
2
cat input.txt
3
seq 10
4
cat input.txt | awk '{a=0;for(i=1;i<=NF;i++){a+=$i};print a}'
5
seq 9 | awk 'BEGIN{a=0;b=1;print a;print b}{c=a+b;print c;a=b;b=c}'
6
echo "scale=11; 4*a(1)" | bc -l | cut -c 1-12
7
echo "scale=101; 4*a(1)" | bc -l | tr -d '\n' | tr -d '\\' | cut -c 1-102
8
cat input.txt | awk '{for(i=0;i<10;i++){for(j=0;j<10;j++){if(i+j==$1&&i*2+j*4==$2){print i, j}}}}'
9
cat input.txt | xargs | sed -E 's;([0-9]*/[0-9]*/[0-9]*);\n\1;g' | sort -r -k 1,1 | awk '{for(i=1;i<=NF;i++){print $i};printf("\n")}'
10
cat input.txt | sed -e '2 s/は に/は川に/' | sed 's/ん が/ん魚が/;s/は に/は新幹線に/;s/、 が/、富士山が/'
11
cat input.txt | rs -T | awk '{print $3,$2,$1}'
12
cat input.txt | tr 01 10
13
echo {a..z} | tr $(cat input.txt) ' ' | awk '{print $1}'
14
cat input.txt | sort -s -k 2,2 | awk 'BEGIN{a=1;printf("%d",a)}{if($2==a){printf(" %s",$1)}else{a+=1;printf("\n%d %s",a,$1)}}'
15
cat input.txt | factor | awk '{if(NF==2){print "YES"}else{print "NO"}}'
16
cat input.txt
17
cat input.txt | awk 'BEGIN{a=0}{b[a]=$1;a+=1}END{for(i=0;i<length(b);i++){for(j=i+1;j<length(b);j++){if(b[i]>b[j]){c=b[i];b[i]=b[j];b[j]=c}}};for(k=0;k<length(b);k++){print b[k]}}'
18
cat input.txt | awk 'BEGIN{a=1;b=100}{if($2==">"){if(a<$3){a=$3}}else{if(b>$3){b=$3}}}END{for(i=1;i<=100;i++){if(i>a&&i<b){print i}}}'
19
cat input.txt | awk '{print substr($0,1,length($0)/3)}'
20
cat input.txt | awk '{z=$0;a=0;for(i=2;i<=z;i++){if(z%i==0){z/=i;a=1;printf("%d ",i);i=1}};printf("\n")}' | awk '{if(NF==1){print "素数"}else{for(i=1;i<=NF;i++){printf("%d ",$i)}printf("\n")}}' | sed 's/ $//g'
21
cat input.txt | awk '{a=0;for(i=1;i<length($0);i++){if(substr($0,i,1)!=substr($0,length($0)-i+1,1)){a=1}};if(a==0){print "YES"}else{print "NO"}}'
22
echo 'l(2)/l(10)' | bc -l | awk '{printf("%lf*1024\n",$0)}' | bc -l | awk '{print int($0)+1}'
23
cat input.txt | awk '{z=0;for(i=1;i<=length($0);i++){a=substr($0,i,1);if(a=="A"||a=="B"||a=="C"){z+=1}else if(a=="D"||a=="E"){z+=2}else{z+=3}};print z}'
24
echo | awk '{m=0;for(a=0;a<14;a++){for(b=0;b<19;b++){for(c=0;c<12;c++){for(d=0;d<24;d++){for(e=0;e<11;e++){if(a*15+b*11+c*18+d*8+e*21<=185&&a*121+b*86+c*162+d*68+e*187>m){m=a*121+b*86+c*162+d*68+e*187}}}}}};print m}'
25
echo {A,B,C}{A,B,C}{A,B,C} | xargs -n1 | awk '{if(substr($0,1,1)!=substr($0,2,1)&&substr($0,1,1)!=substr($0,3,1)&&substr($0,2,1)!=substr($0,3,1)){print $0}}'
26
cat input.txt | sed -E 's/(.)/\1 /g' | awk '{for(i=1;i<=NF;i++){a[NR,i]=$i}}END{for(i=1;i<=5;i++){for(j=1;j<=5;j++){b[i,j]=999}};b[1,1]=0;c=0;while(c==0){for(i=1;i<=5;i++){for(j=1;j<=5;j++){if(a[i,j]!="#"){if(i>1&&a[i-1,j]!="#"&&b[i-1,j]+1<b[i,j]){b[i,j]=b[i-1,j]+1};if(j>1&&a[i,j-1]!="#"&&b[i,j-1]+1<b[i,j]){b[i,j]=b[i,j-1]+1}}}};if(b[5,5]!=999){c=1;print b[5,5]} }}'
27
cat input.txt | sed 's/://g' | awk '{print $1,$3,$4,$6}' | awk '{printf("%s %s %04d %04d\n",$1,$2,$3,$4)}' | awk 'BEGIN{a["A"]="0759";a["B"]="9999";a["C"]="9999";a["D"]="9999"}{if(a[$1]<$3&&a[$2]>$4){a[$2]=$4}}END{print a["D"]}' | sed -E 's/(..)(..)/\1:\2/g' | sed 's/^0//g'
28
echo | awk '{for(i=0;i<5;i++){for(j=0;j<5;j++){if(i==0||i==4||j==0||j==4){printf("3")}else if((i==1||i==3||j==1||j==3)){printf("2")}else{printf("1")}};printf("\n")}}'
29
echo | awk 'BEGIN{for(i=0;i<5;i++){for(j=0;j<5;j++){a[i,j]=10}}}{i=2;j=3;n=11;f=0;d=1;d2=1;p=0;while(1){a[i,j]=n;n+=1;if(i==0&&j==4||(i>4&&j>4)){break};if(d>0){d-=1}else if(d==0){d=d2;if(p==1){d2+=1;p=0}else{p=1};f+=1};if(f>3){f=0};if(f==0){i+=1}else if(f==1){j-=1}else if(f==2){i-=1}else if(f==3){j+=1}}}END{for(i=0;i<5;i++){for(j=0;j<5;j++){printf("%d ",a[i,j])};printf("\n")}}' | sed 's/ $//g'
30
cat input.txt | sed -E 's/(.)/\1\n/g' | awk '{if($1=="A"){print "S"}else if($1=="B"){print "T"}else if($1=="C"){print "U"}else if($1=="D"){print "V"}else if($1=="E"){print "W"}else if($1=="F"){print "X"}else if($1=="G"){print "Y"}else if($1=="H"){print "Z"}else if($1=="I"){print "A"}else if($1=="J"){print "B"}else if($1=="K"){print "C"}else if($1=="L"){print "D"}else if($1=="M"){print "E"}else if($1=="N"){print "F"}else if($1=="O"){print "G"}else if($1=="P"){print "H"}else if($1=="Q"){print "I"}else if($1=="R"){print "J"}else if($1=="S"){print "K"}else if($1=="T"){print "L"}else if($1=="U"){print "M"}else if($1=="V"){print "N"}else if($1=="W"){print "O"}else if($1=="X"){print "P"}else if($1=="Y"){print "Q"}else if($1=="Z"){print "R"}}' | xargs | sed 's/ //g'
31
cat input.txt | xargs | awk '{a=0;for(i=1;i<=1024;i++){if($1%i==0&&$2%i==0&&$3%i==0){a=i}};print a}'
32
cat input.txt | xargs | awk '{a=$1;for(i=100;i>=1;i--){for(j=100;j>=1;j--){for(k=100;k>=1;k--){if($1*i==$2*j&&$2*j==$3*k){a=$1*i}}}};print a}'
33
cat input.txt | awk '{print substr($1,1,1), length($1)}'
34
cat input.txt | factor | xargs -n1 | awk 'NR>1' | xargs | awk '{for(i=1;i<=NF/5;i++){print $i}}' | awk 'BEGIN{a=1}{a=a*$1}END{print a}'
35
cat input.txt | awk '{print $1,$1}' | xargs -n1
36
cat input.txt | awk '{for(i=0;i<s$1;i++){print $1}}'
37
cat input.txt | sed 's/[^0-9]/ /g' | awk '{for(i=1;i<=NF;i++){print $i}}'
38
cat input.txt | awk '{if($1%$2==0){print "Yes"}else{print "No"}}'
39
cat input.txt | sed 's/\([a-z]\)/\1\n/g' | uniq -u | tr -d '\n'
40
cat input.txt | sed 's/\([a-z]\)/\1\n/g' | sort | uniq -c | awk 'NR>1{print $2,$1}'
41
cat input.txt | awk 'NR==1{a=$1+$2+$3;print $0}NR==2{x=a-$1-$3;print $1,x,$3}NR==3{print $0}'
42
cat input.txt | awk 'NR==1{a=$1+$2+$3+$4+$5}NR==3{x=a-$1-$2-$4-$5;print $1,$2,x,$4,$5}NR!=3{print $0}' | sed '3 s/\( [0-9] \)/ \1/g;3 s/\( [0-9]$\)/ \1/g'
43
cat input.txt | awk '{print $1".png",$1".jpg"}'
44
find ShellGeiData/vol.68 -type f | xargs -I@ grep entrepreneurial -rl @ | awk -F'/' '{print $NF}'
45
echo | awk '{for(i=0;i<6;i++){for(j=0;j<6;j++){if(i>=3&&j<3){printf("3")}else if(i<3&&j<3){printf("2")}else if(i<3&&j>=3){printf("1")}else if(i>=3&&j>=3){printf("4")}};printf("\n")}}'
46
cat input.txt | awk '{for(i=0;i<$1;i++){for(j=0;j<$1;j++){if(i==j){printf("1")}else{printf("0")}}printf("\n")}}'
47
cat input.txt | sed "s/ /\n/g" | grep -E "[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+"
48
cat input.txt | tr -d '\n' | sed 's/\([a-z]\)/\1\n/g' | uniq -c | awk '{print $2,$1}' | tr -d ' ' | tr -d '\n'
1
echo | awk '{print "SHELLGEI ONLINE JUDGE"}'
2
cat input.txt | awk '{print $2}'
3
cat input.txt | awk '{print $1,$3,$2}'
4
cat input.txt | awk 'BEGIN{cnt=0}{cnt+=1}END{print cnt}'
5
echo | awk '{for(i=1;i<=10;i++){print i}}'
6
cat input.txt | awk '{if($0%2==0){print "EVEN"}else{print "ODD"}}'
1
cat input.txt
2
cat -n input.txt
3
cat -e input.txt
4
cat input.txt /ShellGeiData/vol.65/input
1
echo "SHELLGEI ONLINE JUDGE"
2
echo -e "SHELLGEI
ONLINE
JUDGE"
3
echo $SHELL
1
find "/ShellGeiData/sd201701/" | sort
2
find "/ShellGeiData/sd201701" -type f | sort
3
find "/ShellGeiData/sd201701" -type f -name "dangerous*" | sort
1
cat input.txt | grep ".jpg"
2
cat input.txt | grep -e ".jpg" -e ".png"
3
cat input.txt | grep -v ".txt"
4
cat input.txt | grep ".jpg$"
1
cat input.txt | sed "s/XXX/SHELLGEI/"
2
cat input.txt | sed "s/XXX/SHELLGEI/;s/YYY/ONLINE/"
3
cat input.txt | sed "s/[0-9]//g"
4
cat input.txt | sed "/[0-9]/d"
5
cat input.txt | sed -n "/[0-9]/p"
6
cat input.txt | sed "s/\([a-z]*[0-9]\)/\1.jpg/"
1
cat input.txt | sort
2
cat input.txt | sort -r
3
cat input.txt | sort -u
1
cat input.txt | sort | uniq
2
cat input.txt | sort | uniq -c
1
cat input.txt | wc -l
2
cat input.txt | wc -w
3
cat input.txt | wc -m
1
convert -size 200x200 xc:#FF0000 media/output.jpg
2
convert -size 200x200 xc:#FF0000 jpg:- | convert - -stroke "#000000" -strokewidth 50 -draw "line 0,100 200,100" media/output.jpg
3
convert -size 200x200 xc:#FF0000 jpg:- | convert - -draw "circle 100,100 100,150" media/output.jpg
4
convert -size 200x200 xc:#FF0000 jpg:- | convert - -draw "rectangle 0,0 100,100" - | convert - -draw "rectangle 100,100, 200, 200" media/output.jpg
5
convert -size 200x200 xc:#FF0000 media/output.jpg; for i in {0..9};do for j in {0..9};do convert media/output.jpg -draw "rectangle $((i*20+5)),$((j*20+5)) $((i*20+15)),$((j*20+15))" media/output.jpg; done; done
NULL
NULL
NULL
NULL
NULL
NULL
NULL