Difference between revisions of "Scripting"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
(export-import does not work with "\n")
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
 
= Usecases =
 
= Usecases =
 
Delete linebreaks
 
Delete linebreaks
  [[cat]] ''file'' | tr '\
+
  [[cat]] ''file'' | tr '\n' '; ' > ''newfile''
' '; ' > ''newfile''
 
  
 
= TroubleShooting =
 
= TroubleShooting =
Line 15: Line 14:
  
 
= See also =
 
= See also =
* [[sHell programming]]
+
* [[shell programming]]

Latest revision as of 12:35, 23 January 2014

foo()
{
}

defines a function in bash.

Usecases

Delete linebreaks

cat file | tr '\n' '; ' > newfile

TroubleShooting

If you want every line to be shown with evaluated values, write the following to the beginning of the script:

set -x

or -xv for verbose

See also