User Tools

Site Tools


tutorials:bash_scripting:part3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:bash_scripting:part3 [2012/05/29 10:46] rmilestutorials: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 in a configuration file when I log into a session. Grep in this case will be used to print lines matching a given pattern to stdout. Sed will be used to print only one line piped from grep to stdout. Awk will be used to print just one field from the line piped in from sed. 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 in a configuration file when I log into a session. Grep in this case will be used to print lines matching a given pattern to stdout. Sed will be used to print only one line piped from grep to stdout. Awk will be used to print just one field from the line piped in from sed.
  
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:
 <code> <code>
-cat /proc/asound/cards | grep CMI | sed q | awk -F " " '{ print $}'+cat /proc/asound/cards | grep CMI | sed q | awk -F " " '{ print $}'
 </code> </code>
 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:
 </code> </code>
  
 +----
 +
 +**Cheers!**
  
  
Line 129: Line 133:
  
  
- \npcm.copy {defaults.ctl.card 1\npcm.copy {defaults.ctl.card 1 ~/.asoundrc 
-echo \npcm.copy { 
tutorials/bash_scripting/part3.1338252416.txt.gz · Last modified: 2017/10/12 21:58 (external edit)