Linux命令随记:修订间差异
无编辑摘要 |
小 (→实验记录补充) |
||
第1行: | 第1行: | ||
记一下一些我觉得我容易忘掉的组合命令吧。。 | 记一下一些我觉得我容易忘掉的组合命令吧。。 | ||
== 命令参数使用 == | ==命令参数使用== | ||
find -type f -size +10M -exec ls -lh {} \; | find -type f -size +10M -exec ls -lh {} \; | ||
ls /dev/sd{a,b} | ls /dev/sd{a,b} | ||
=== <big>使用如下命令,结果显示的是当前所有可用的麦克风设备:</big> === | ===<big>使用如下命令,结果显示的是当前所有可用的麦克风设备:</big>=== | ||
<blockquote>pi@raspberrypi:~ $ arecord -l</blockquote><blockquote>**** List of CAPTURE Hardware Devices ****</blockquote><blockquote>card 1: CameraB409241 [USB Camera-B4.09.24.1], device 0: USB Audio [USB Audio]</blockquote><blockquote> Subdevices: 1/1</blockquote><blockquote> Subdevice #0: subdevice #0</blockquote> | <blockquote>pi@raspberrypi:~ $ arecord -l</blockquote><blockquote>**** List of CAPTURE Hardware Devices ****</blockquote><blockquote>card 1: CameraB409241 [USB Camera-B4.09.24.1], device 0: USB Audio [USB Audio]</blockquote><blockquote> Subdevices: 1/1</blockquote><blockquote> Subdevice #0: subdevice #0</blockquote> | ||
=== <big>使用如下命令,结果显示的是当前所有可用的音频输出设备:</big> === | ===<big>使用如下命令,结果显示的是当前所有可用的音频输出设备:</big>=== | ||
<blockquote>pi@raspberrypi:~ $ aplay -l</blockquote><blockquote>**** List of PLAYBACK Hardware Devices ****</blockquote><blockquote>card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]</blockquote><blockquote> Subdevices: 8/8</blockquote><blockquote> Subdevice #0: subdevice #0</blockquote><blockquote> Subdevice #1: subdevice #1</blockquote><blockquote> Subdevice #2: subdevice #2</blockquote><blockquote> Subdevice #3: subdevice #3</blockquote><blockquote> Subdevice #4: subdevice #4</blockquote><blockquote> Subdevice #5: subdevice #5</blockquote><blockquote> Subdevice #6: subdevice #6</blockquote><blockquote> Subdevice #7: subdevice #7</blockquote><blockquote>card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]</blockquote><blockquote> Subdevices: 1/1</blockquote><blockquote> Subdevice #0: subdevice #0</blockquote> | <blockquote>pi@raspberrypi:~ $ aplay -l</blockquote><blockquote>**** List of PLAYBACK Hardware Devices ****</blockquote><blockquote>card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]</blockquote><blockquote> Subdevices: 8/8</blockquote><blockquote> Subdevice #0: subdevice #0</blockquote><blockquote> Subdevice #1: subdevice #1</blockquote><blockquote> Subdevice #2: subdevice #2</blockquote><blockquote> Subdevice #3: subdevice #3</blockquote><blockquote> Subdevice #4: subdevice #4</blockquote><blockquote> Subdevice #5: subdevice #5</blockquote><blockquote> Subdevice #6: subdevice #6</blockquote><blockquote> Subdevice #7: subdevice #7</blockquote><blockquote>card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]</blockquote><blockquote> Subdevices: 1/1</blockquote><blockquote> Subdevice #0: subdevice #0</blockquote> | ||
第20行: | 第20行: | ||
systemctl daemon-reload | systemctl daemon-reload | ||
== 理论 == | ==理论== | ||
<blockquote>Bash 有个功能叫大括号扩展,大括号包围的,用逗号隔开的参数会扩展为独立的多个参数。</blockquote><blockquote>花括号用来匹配一组用逗号分隔的字符串中的任一个。左花括号之前的所有字符称为前文(preamble),右花括号之后的所有字符称为后文(preamble)。前文和后文都是可选的。花括号中不能包含不加引号的空白符。</blockquote> | <blockquote>Bash 有个功能叫大括号扩展,大括号包围的,用逗号隔开的参数会扩展为独立的多个参数。</blockquote><blockquote>花括号用来匹配一组用逗号分隔的字符串中的任一个。左花括号之前的所有字符称为前文(preamble),右花括号之后的所有字符称为后文(preamble)。前文和后文都是可选的。花括号中不能包含不加引号的空白符。</blockquote> | ||
== 实验记录 == | ==实验记录== | ||
使用 ls 命令配合测试大括号扩展特性1 | |||
前提: touch test1 test2 test3 test4 test10 | |||
预期结果: test1 test2 test3 test4 test10 be showed | |||
{| class="wikitable" | {| class="wikitable" | ||
!ls | ! colspan="3" |ls | ||
|- | |||
|ls test[1,4] | |||
|test1 test4 | |||
|× | |||
|- | |- | ||
|ls | |ls test[1,10] | ||
|test1 | |||
|× | |||
|- | |||
|ls test[1-9] | |||
|test1 test2 test3 test4 | |||
|√ | |√ | ||
|- | |- | ||
|ls | |ls test[1-10] | ||
|test1 | |||
|× | |× | ||
|- | |- | ||
|ls | | | ||
| | |||
| | |||
|- | |||
|ls test{1,9} | |||
|ls: cannot access 'test9': No such file or directory | |||
test1 | |||
|× | |× | ||
|- | |- | ||
|ls | |ls test{1,4} | ||
| | |test1 test4 | ||
|x | |||
|- | |||
|ls test{1-9} | |||
|ls: cannot access 'test{1-9}': No such file or directory | |||
|x | |||
|- | |||
|ls test{1-10} | |||
|ls: cannot access 'test{1-10}': No such file or directory | |||
|x | |||
|- | |- | ||
|going to completed | |going to completed | ||
| | | | ||
| | |||
|} | |||
使用 touch 命令配合测试大括号扩展特性1 | |||
预期结果: touch testa testb testc testd | |||
实验结果: | |||
{| class="wikitable" | |||
! colspan="2" |touch | |||
! | |||
|- | |||
|touch test[a,d] | |||
|只有 test[a,d] 文件 | |||
|× | |||
|- | |||
|touch test[a-d] | |||
|只有 test[a-d] 文件 | |||
|× | |||
|- | |||
|touch test{a-d} | |||
|只有 test{a-d}文件 | |||
|× | |||
|- | |||
|touch test{a,d} | |||
|有testa, testd文件 | |||
|×× | |||
|} | |} | ||
使用 touch 命令配合测试大括号扩展特性2 | |||
预期结果: touch test1 test2 test3 test4 | |||
实验结果: | |||
{| class="wikitable" | |||
! colspan="2" |touch | |||
! | |||
|- | |||
|touch test[1,4] | |||
|只有 test[1,4] 文件 | |||
|× | |||
|- | |||
|touch test[1-4] | |||
|只有 test[1-4] 文件 | |||
|× | |||
|- | |||
|touch test{a-d} | |||
|只有 test{1-4}文件 | |||
|× | |||
|- | |||
|touch test{a,d} | |||
|有test1, test4文件 | |||
|×× | |||
|} | |||
????????going to completed | |||
[[分类:Linux]] | [[分类:Linux]] |
2019年12月10日 (二) 18:47的版本
记一下一些我觉得我容易忘掉的组合命令吧。。
命令参数使用
find -type f -size +10M -exec ls -lh {} \;
ls /dev/sd{a,b}
使用如下命令,结果显示的是当前所有可用的麦克风设备:
pi@raspberrypi:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: CameraB409241 [USB Camera-B4.09.24.1], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
使用如下命令,结果显示的是当前所有可用的音频输出设备:
pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
apt-get install sox libsox-fmt-all
libsox-fmt-all包含mp3的解码器和其它格式的解码器。
播放音乐:
$ play Crystals.mp3 systemctl daemon-reload
理论
Bash 有个功能叫大括号扩展,大括号包围的,用逗号隔开的参数会扩展为独立的多个参数。
花括号用来匹配一组用逗号分隔的字符串中的任一个。左花括号之前的所有字符称为前文(preamble),右花括号之后的所有字符称为后文(preamble)。前文和后文都是可选的。花括号中不能包含不加引号的空白符。
实验记录
使用 ls 命令配合测试大括号扩展特性1
前提: touch test1 test2 test3 test4 test10
预期结果: test1 test2 test3 test4 test10 be showed
ls | ||
---|---|---|
ls test[1,4] | test1 test4 | × |
ls test[1,10] | test1 | × |
ls test[1-9] | test1 test2 test3 test4 | √ |
ls test[1-10] | test1 | × |
ls test{1,9} | ls: cannot access 'test9': No such file or directory
test1 |
× |
ls test{1,4} | test1 test4 | x |
ls test{1-9} | ls: cannot access 'test{1-9}': No such file or directory | x |
ls test{1-10} | ls: cannot access 'test{1-10}': No such file or directory | x |
going to completed |
使用 touch 命令配合测试大括号扩展特性1
预期结果: touch testa testb testc testd
实验结果:
touch | ||
---|---|---|
touch test[a,d] | 只有 test[a,d] 文件 | × |
touch test[a-d] | 只有 test[a-d] 文件 | × |
touch test{a-d} | 只有 test{a-d}文件 | × |
touch test{a,d} | 有testa, testd文件 | ×× |
使用 touch 命令配合测试大括号扩展特性2
预期结果: touch test1 test2 test3 test4
实验结果:
touch | ||
---|---|---|
touch test[1,4] | 只有 test[1,4] 文件 | × |
touch test[1-4] | 只有 test[1-4] 文件 | × |
touch test{a-d} | 只有 test{1-4}文件 | × |
touch test{a,d} | 有test1, test4文件 | ×× |
????????going to completed