tutorials:bash_scripting:part3
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:bash_scripting:part3 [2012/05/29 10:40] – rmiles | tutorials:bash_scripting:part3 [2017/10/12 21:58] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
//**3. Creating a configuration file on the fly and stream editing**// | //**3. Creating a configuration file on the fly and stream editing**// | ||
- | Someone on the list asked If I'd do something with stream editors. In this tutorial I'll use pipes, grep, sed and awk to help set a variable | + | ---- |
+ | Someone on the list asked If I'd do something with stream editors. In this tutorial I'll use pipes, grep, sed and awk to help set a variable | ||
Grep is a pattern matcher, sed is a non interactive editor that acts on streams piped into it and awk is actually a pattern matching programming language that is quite handy. Some of the things you can do with sed you can do with grep and some of the things you can do with awk you can do with sed and there are even other applications that could have been used but his is how I solved this problem. | Grep is a pattern matcher, sed is a non interactive editor that acts on streams piped into it and awk is actually a pattern matching programming language that is quite handy. Some of the things you can do with sed you can do with grep and some of the things you can do with awk you can do with sed and there are even other applications that could have been used but his is how I solved this problem. | ||
Line 7: | Line 8: | ||
Sound confusing? There are more ways than one to stream edit a cat. | Sound confusing? There are more ways than one to stream edit a cat. | ||
- | I have a C-Media PCI sound card installed on my desktop box which also has onboard | + | I have a C-Media PCI sound card installed on my desktop box which also has on board sound via an NVidia chip. |
- | I have disabled the NVIDIA chip in the BIOS. However, it is still listed in / | + | I have disabled the NVIDIA chip in the BIOS. However, it is still listed in / |
< | < | ||
rick[~]$ cat / | rick[~]$ cat / | ||
Line 32: | Line 33: | ||
} | } | ||
</ | </ | ||
- | In order to have the correct | + | In order to have the correct |
The basic script will will create an ~/.asoundrc on the fly. The output of each echo command is redirected to the file ~/.asoundrc when the script runs. | The basic script will will create an ~/.asoundrc on the fly. The output of each echo command is redirected to the file ~/.asoundrc when the script runs. | ||
Line 59: | Line 60: | ||
This is where stream editing comes in. I can use a variable for the card number and create the variable each time the script is run using the following: | This is where stream editing comes in. I can use a variable for the card number and create the variable each time the script is run using the following: | ||
< | < | ||
- | cat / | + | cat / |
</ | </ | ||
The stdout from each command is piped to the next command until just the card number remains. | The stdout from each command is piped to the next command until just the card number remains. | ||
Line 117: | Line 118: | ||
</ | </ | ||
+ | ---- | ||
+ | |||
+ | **Cheers!** | ||
Line 129: | Line 133: | ||
- | | ||
- | echo |
tutorials/bash_scripting/part3.1338252013.txt.gz · Last modified: 2017/10/12 21:58 (external edit)