I want to create a simple file....with the command

Example:

touch file.txt

ok its created *BUT*

****I want to edit this file in shell and save it, writing EOF to finish.

Any suggestions? How i do that? Thanks!

Edited 5 Years Ago by aFg3: n/a

You'd better post shell scripting related kind of threads here
any way ,you can edit it like this

cat > file.txt
Hello, I am a linux user myself.
EOF

and press [ctrl]+[c] keys to save it.
And if you want to use c for that purpose.then

#include <stdio.h>
int main(){
FILE* fptr;
if((fptr=fopen("file.txt","w"))==NULL)
    return 1;
fputs("I am a linux user myself\n",fptr);
fclose(fptr);
return 0;
}

And you don't need to write the word "EOF" to make c able to know where your file ends, if that's what you're trying to do.

Edited 5 Years Ago by D33wakar: n/a

You'd better post shell scripting related kind of threads here
any way ,you can edit it like this

cat > file.txt
Hello, I am a linux user myself.
EOF

and press [ctrl]+[c] keys to save it.
And if you want to use c for that purpose.then

#include <stdio.h>
int main(){
FILE* fptr;
if((fptr=fopen("file.txt","w"))==NULL)
    return 1;
fputs("I am a linux user myself\n",fptr);
fclose(fptr);
return 0;
}

And you don't need to write the word "EOF" to make c able to know where your file ends, if that's what you're trying to do.

Thankss ur the best!

This article has been dead for over six months. Start a new discussion instead.