Create YAML file in terminal - MacOS - macos

Either I'm too stupid or I can't find the right command.
How can I create a simple YAML file using the ZSH terminal?

You can create yml file like these commands
echo "basic" > basic.yml or touch simple.yml

YAML is just a format so you can create any text file and just add an .yml or .yaml extension.
Command for creating files in zsh is touch
touch test.yaml
What people usually do is to just open a terminal text editor like nano or vim add the content and save as *.yml or *.yaml

Related

replacing config file with another via script

I have an app that has a config file. Is there a way to replace all the text in the file with other text i have. Instead of using sed to modify the current file. Id like to just rip all the text from the file and add in my own file then save the changes, Ideally this will be run with the user signed in as the user or sudo as well so permissions should be ok.
file location: ~/Library/Application \Support/App/config_file.json
How about this?
cat < other_file > my-config.json

How to create a file using goorm terminal

Hi i am not able to figure out what is the command for creating a file from terminal in Goorm ide . Just to make clear i want to create new file only from terminal not by gui.
Just like in other Linux terminals, you can type touch filename to create a file via goormIDE terminal.
FYI:
Type mkdir foldername to create a directory
Type goorm filename to open a file in goormIDE editor
goormide is ubuntu os.
so you can create files by typing common linux commands like touch data.json

How does one locate a .zshrc file?

I used Homebrew to install Z shell (zsh) 5.0.7 on my Mac.
For the life of me, .zshrc is nowhere to be found. It is not in ~. Is is not in /etc or /etc/zshrc as they suggest here: http://zshwiki.org/home/config/files
Am I supposed to create it myself?
Sure. If it's not there already, create it yourself.
$ touch ~/.zshrc
You can run the helper script zsh-newuser-install from the prompt, and it will walk you through the process to create an initial .zshrc in your home directory.
As kyranjamie mentioned, you can create it using following command
$ touch ~/.zshrc
Example content of .zshrc file:
PATH=$PATH:/your_path_goes_here
In order to find any file on a Unix-based system, you can try the command:
$ locate filename
It should list all the paths where the corresponding file exists.
In Unix based systems, touch command followed by name will create an empty file in the present directory.
the modification and access time of each file is also updated with the use of touch command.
In your case, to create .zshrc file, you can use the touch command as :
$ touch ~/.zshrc

Custom command to create and open multiple files in terminal

I'm wondering if there is a way to create and open multiple files in terminal using a custom one-liner terminal command using OSX 10.9.4.
like $ makemore test.rb test2.rb
then it opens using my default Sublime Text3
I found the custom command to create and open a single file.
lazy()
{
touch $1
open $1
}
Is this possible to make something that makes, then opens multiple files?
P.S. Thanks to this Stackoverflow question for how to make custom command to create and open a single file. How can I create and open a file from terminal with a single command?
lazy() { for x; do touch "$x"; open "$x"; done; }
Then call it with a list of file names.

open a folder from a name in txt file BASH

I have a text file fold.txt that contains one line fold_nam:
$ cat fold.txt
fold_nam
This name in the the text file is an output that was created during a program run of a folder's name that now contains other files that I need to work with.
I am writing a big script and now I need to enter this folder and I need to get the name from the text file. I tried several things but cannot really work it out.
There's no need to use cat:
cd $(<fold.txt)
If you want to read the line into a variable: read -r folder_name < fold.txt
You should be able to do this:
cd $(cat fold.txt)
or
cd `cat fold.txt`

Resources