Linux do some cool things or funny things

1. File randomizer

This project came to my mind when I was trying to burn some music for my car. The car did not have the ability to shuffle play so I decided to randomize the file order. But the default burning tool did not have an option to shuffle files before burning, so I decided to make this small script. This is the full script:

#!/bin/bash 
num_files=$(ls | wc -l) 
pad=$(echo "l($num_files)/l(10) + 1" | bc -l) 
pad=${pad%.*} 

counter=0 
ls -A | shuf | while read filename; do num=$(printf "%0${pad}d" $counter); mv "$filename" "$num - $filename"; counter=$(($counter+1)); done;

1. funny terminal

  • The fortune | cowsay is quite known. But to spice things up, use
    lolcat

    這裏寫圖片描述


  • Other things quite famous are figlet and toilet

這裏寫圖片描述


  • Espeak is a text-to-speech programe

  • nyancat(gif)
    這裏寫圖片描述

  • vtop is another nice command (install via npm) This uses braille characters to make the plot!
    這裏寫圖片描述

  • cmatrix
    這裏寫圖片描述

  • Install sl, so when you misspel ls, you get this: (gif)
    這裏寫圖片描述

  • Install filters to have
    這裏寫圖片描述

- easy terminal

  • remove empty directories
find -type d -empty -exec rm {} \; # remove empty directories
  • convert bases to other bases
echo "obase=16;ibase=10;500000" | bc
  • find the years in which 21 november is a friday
for y in {1970..2010} ; do date -d $y-11-21 +%u-%Y ; done | grep -P "(?<=5-).*"
  • find out how many files sit in a directory
ls -l | wc -l
  • get a list of the ASCII files in the directory
file * | grep ASCII | awk -F: {'print $1'}
  • create a hexdump
cat file | hexdump -c
發佈了85 篇原創文章 · 獲贊 13 · 訪問量 13萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章