Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I create a file with the contents "echo hello world" with the name in one line?

share|improve this question

closed as off topic by Kyle Smith, womble, Lucas Kauffman, Khaled, Wesley Apr 6 '12 at 1:38

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 4 down vote accepted

Just use echo and direct the output to the file:

echo "echo hello world" >
share|improve this answer

In a terminal, you could:

  • Use echo to place a line in a file, like echo 'echo hello world' >
  • Use vi to edit (vi Once in the editor you would use i to enter Insert mode, type the contents you wish the file to have, then press Esc to enter Normal mode. In Normal mode, you would use :wq to save the file and exit vi.
  • Use nano to edit the file (nano nano is a simpler editor without "modes". You simply type the contents you want and use Ctrl + O to save the file, and Ctrl + X to exit nano.

If you have access to a graphical environment, there are many text editors you can use and they depend mainly on the desktop environment provided by your distribution.

  • In GNOME 2, you could use gedit. It's typically under Applications > Accessories > Text Editor.
  • In GNOME 3, you would also use gedit, but you would find it by pressing Super (Also known as the Windows Key) and scrolling through the icons (or beginning to type "Text Editor").
  • In KDE, you could use kate. It's found in the main menu under Accessories.
share|improve this answer
thxs but was looking for a one-liner – DD. Apr 4 '12 at 10:29
My first bullet point is a one-liner. – Kyle Smith Apr 4 '12 at 10:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.