I'm learning how to use the terminal and manage unix and I was wondering what is the way to make a .txt and a .csv to store some text information.
CodePudding user response:
Navigate to the desired directory, e.g.
cd Documents/SomeFolder
Run
touch fileName.txt
to create the file.Run
nano fileName.txt
orvim fileName.txt
to edit the file with nano or vim respectively.*
P.S. you can also skip the second step as once you exit and save the file it will automatically save it to the directory if it does not exist yet, so creating the file prior is not necessary.
*I prefer using nano as it is simple to use, once you are done editing simply press ctrl x
and it will prompt if you want to save before exiting. Vim is slightly more complex and you need to press i
to enter insertion (editing) mode, then once you are done you need to press esc
to exit insertion mode and then type :wq
and enter to save.
CodePudding user response:
echo "this is some text" > file.txt
echo "name,age,address" > file.csv
echo "Bob,37,123 Main St." >> file.csv
cat << EOF >> file.csv
Alice,34,23 Elm St.
Charlie,23,60 E. Birch Ave.
EOF