====== Catatan Bash Command Linux ======
Beberapa catatan bash command linux
===== LS Modified File =====
Perintah LS Menampilkan File modifikasi terakhir
ls -1tr /folder/
===== LS Ignore file string =====
Perintah LS mengabaikan string file tertentu
ls -l /folder/ --ignore=*.java
===== Determinte Variable Empty or Not =====
Menentukan atau mengecek variable kosong atau berisi
ini apabila variable kosong
if [[ -z $variable ]]
if [[ -z "$variable" ]]
dan ini apabila tidak kosong
if [[ ! $variable ]]
if [[ ! "$variable" ]]
===== Bash Loop From LS =====
Looping dari hasil ls
bisa dengan cara ini
for task in $(ls -1tr $task_file | head -3); do
...
...
done
atau anda bisa menyimpan command di dalam string kemudian mengeksekusi dengan eval. contoh seperti ini.
command=ls -1tr $task_file --ignore=*.auto | head -3
if [[ -z $command ]]; then
cmd='ls -1tr $task_file | head -3'
else
cmd='ls -1tr $task_file --ignore=*.auto | head -3'
fi
for task in $(eval $cmd); do
...
...
done
===== TOP -c command =====
Top menampilkan proses linux filter berdasarkan command
top -bc |grep name_of_process
sumber : http://stackoverflow.com/a/24273554
===== Mendapatkan Lokasi Path Saat ini - Current Working Path =====
Berikut ini adalah command bash untuk mendapatkan lokasi pointer saat ini
$ echo "$PWD"
===== Merubah Nama File Mengandung Underscore =====
Merubah nama file yang mengandung underscore dengan nama lain
rename "_" "bb" /path/*.mp3