Bashrc
重用這個單線的正確方法是什麼?
我最近想出了以下單線:
for f in *.mp3; do sha1sum $f | sed -r 's/[a-z]//g' | cut -c1-2 | awk '{ print ($1 >= 255) ? $1 - $1 + (1/3)*$1 : $1 }' | xargs -i id3v2 -T {} $f; done
我需要它是因為我有一個沒有隨機播放功能的 MP3 播放器。這是我能找到的唯一方法(在大約一個小時的嘗試中)給一個適當的隨機分佈來跟踪名稱。(起初我使用
jot
,但是這個程序並沒有經常更新它的隨機種子來產生任何類似隨機結果的東西。順便說一下,如果有人能想到一個真正有效的好方法,我很想听聽它。)我嘗試將其儲存為別名並得到:
awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error awk: cmd. line:1: { print ( >= 255) ? - + (1/3)* : } awk: cmd. line:1: ^ syntax error
似乎應該有一種適當簡單的方法將其儲存在我的
.bashrc
.我知道我可以將它寫入一個文件並
chmod +x
在我的內部$path
使用 shebang,但我更喜歡盡可能使用我.bashrc
的東西。
如果您真的不想在自己的文件中包含它,您應該使用 bash function,而不是alias。
你是如何定義你的別名的?如果你寫了類似
alias bla="for f in *.mp3....
你的東西*
可能是空的,如果你沒有轉義它,因為它是在你的 bash 的評估時解釋的,而不是在它執行的時候。$f
等的情況也是如此。其他幾點:為什麼將兩位數 (
cut -c1-2
) 與 255 進行比較?這個數字總是小於100。你為什麼寫$1 - $1 + (1/3)*$1
?這只是 ($1)/3。