Wallpapers Forums Login

How To Create An Empty File With Linux Shell Command Echo

today i wanted to create an empty file with the echo utility. so this is how you do it:

echo > whatever_file_name.txt



now try it and tell me if it worked for you. please. i would like to know your opinion or comments so i can help as much people as i can. now that you learned something from me for free, i would like to learn something from you. thanks

did it work for you?

phatrick Tue Mar 05, 2013
echo > fname.txt
adds a single new line

print > filename.txt
does the same thing without a newline, so gives you a really empty file.
struth Thu Apr 05, 2012
that's way cool, who would of thought touch!, I truly am "touched" lol thanks
Nob Wed Jan 25, 2012
useful, cheers.
Carlos Mon Oct 10, 2011
Ty, it was just what i was looking for
Chris Wed May 26, 2010
Thanks! You just saved me a LOT of time. Blessing upon thee!

-Chris
gabi Sat Mar 06, 2010
yes, it works :) *bonus text, because my comment is too short*
Johan Sun Mar 01, 2009
if you want to create an empty file, use touch:

$ touch filename.txt
Joe Tue Oct 28, 2008
that command will put a newline in the file, so it's not quite empty (at least in ubuntu linux). you can add the -n option to prevent the newline, like so:
echo -n > whatever_file_name.txt

a shorthand way to do the same thing (might depend on your shell though) is:
> whatever_file_name.txt
dW Thu Jul 24, 2008
i am using ubuntu and my operator command does not like to work to create any files. i can use vi, save and exit to create a blank file.

the reasoning behind me wanting a blank file in the first place is because i am creating scripts and the redirction will only work if the file is created and the owner:group are both the current user/ non-root.

please help sudo does not work either

Related Content

Information

Share

wallpaperama | Wallpapers | Forums | Terms Of Service

copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5