Bash Tips and Pitfalls: Difference between revisions

From miki
Jump to navigation Jump to search
(New page: Empty a file named <tt>filename</tt>, keeping the same permission and user/group: <source lang="bash"> >filename </source>)
 
No edit summary
Line 3: Line 3:
<source lang="bash">
<source lang="bash">
>filename
>filename
</source>

Print multi-lines text with '''echo''':

<source lang="bash">
$ echo -e "Some text\n...on 2 lines..." # Enable interpretation of backslash escapes (must be quoted!)
Some text
...on 2 lines...
</source>
</source>

Revision as of 01:17, 19 November 2008

Empty a file named filename, keeping the same permission and user/group:

>filename

Print multi-lines text with echo:

$ echo -e "Some text\n...on 2 lines..."                    # Enable interpretation of backslash escapes (must be quoted!)
Some text
...on 2 lines...