Differences between revisions 1 and 2
Revision 1 as of 2012-09-25 09:02:30
Size: 931
Comment:
Revision 2 as of 2012-09-25 09:06:31
Size: 988
Comment:
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
'ls > list' {{{
ls > list
}}}
Line 15: Line 17:
'set -o noclobber' Try setting noclobber

{{{
set -o noclobber'
}}}
Line 19: Line 25:
'ls > list' {{{
ls > list
Line 21: Line 28:
}}}
Line 26: Line 33:
'ls >| list' {{{
ls >| list  }}}

Use of noclobber

When setting 'noclobber' overwriting the content of an existing file by the '>' redirection operator will not be possible. You might have typed '>' to redirect the output of a certain command to an existing file, while you intended to use '>>' redirection operator. This is where 'noclobber' comes in action, preventing you from accidentally deleting the content of the existing file.

How to use it

ls > list

Try setting noclobber

set -o noclobber' 

Try again

ls > list
bash: list: cannot overwrite existing file 

How to overwrite the file even with noclobber set

If you are determined to overwrite the file you can use the '>|' method. Thus

ls >| list 

List of pages in this category:


CategoryCategory CategoryCategory

NoClobber (last edited 2012-09-27 12:53:11 by Valentin Bajrami)