Depending on what you want the file to contain:
touch /path/to/file
for an empty filesomecommand > /path/to/file
for a file containing the output of some command.eg: grep --help > randomtext.txt echo "This is some text" > randomtext.txt
nano /path/to/file
orvi /path/to/file
(orany other editor emacs,gedit etc
)
It either opens the existing one for editing or creates & opens the empty file to enter, if it doesn’t exist
Related Posts:
- Cannot use mkdir in home directory: permission denied (Linux Lubuntu)
- How can I kill a process by name instead of PID, on Linux?
- How to change the output color of echo in Linux
- Copy multiple files from one directory to another from Linux shell
- Linux Bash: Move multiple different files into same directory
- How do I prevent accidental rm -rf /*?
- What useful things can one add to one’s .bashrc? [closed]
- Cp: target is not a directory
- Read a file line by line assigning the value to a variable
- Why do you need to put #!/bin/bash at the beginning of a script file?
- “Couldn’t find a file descriptor referring to the console” on Ubuntu bash on Windows
- What does export PS1=”\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ ” mean in MacOS’ bash Terminal?
- In the shell, what does ” 2>&1 ” mean?
- How to grep for case insensitive string in a file?
- Difference between wait and sleep
- How do I parse command line arguments in Bash?
- Multi-line string with extra space (preserved indentation)
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- -bash: syntax error near unexpected token `newline’
- How can I check if a directory exists in a Bash shell script?
- Bash script and /bin/bash^M: bad interpreter: No such file or directory [duplicate]
- Passing parameters to a Bash function
- How can I use “:” as an AWK field separator?
- -bash: syntax error near unexpected token `newline’ for display command
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- “while :” vs. “while true” [duplicate]
- How to reload .bashrc settings without logging out and back in again?
- How can I declare and use Boolean variables in a shell script?
- How does “cat << EOF" work in bash?
- How do I compare two string variables in an ‘if’ statement in Bash?
- Is bash a programming language?
- How can I count all the lines of code in a directory recursively?
- Extract file basename without path and extension in bash
- Pass variable from one Jenkins stage to others in sh
- Which characters need to be escaped when using Bash?
- What is cp: cannot stat error in Unix, I get this error when trying to copy thing from one folder to another
- Shell: How to call one shell script from another shell script?
- How can I match a string with a regex in Bash?
- linux command to get size of files and directories present in a particular folder?
- How to use gdb with pipes and stdin
- How to define hash tables in Bash?
- Grep ‘binary file matches’. How to get normal grep output?
- ./configure : /bin/sh^M : bad interpreter
- standard_init_linux.go:178: exec user process caused “exec format error”
- What is cp: cannot stat error in Unix, I get this error when trying to copy thing from one folder to another
- How to check if an environment variable exists and get its value?
- Bash syntax error: unexpected end of file
- Create timestamp variable in bash script
- How do I edit $PATH (.bash_profile) on OS X?
- Check number of arguments passed to a Bash script
- How to modify a global variable within a function in bash?
- choosing between $0 and BASH_SOURCE
- Create a new file in git bash
- How to count lines in a document?
- What does `set -x` do?
- How to specify the private SSH-key to use when executing shell command on Git?
- How to get the process ID to kill a nohup process?
- Fast ping sweep in python
- Writing a simple shell in C using fork/execvp
- Speed up rsync with Simultaneous/Concurrent File Transfers?
- Multi-dimensional arrays in Bash
- Variable interpolation in the shell
- chmod: changing permissions of ‘my_script.sh’: Operation not permitted
- What’s the meaning of the parameter -e for bash shell command line?
- tar: add all files and directories in current directory INCLUDING .svn and so on
- What does set -e mean in a bash script?
- What does set -e mean in a bash script?
- Check existence of input argument in a Bash shell script
- Associative arrays in Shell scripts
- Running programs in parallel using xargs
- Linux find and grep command together
- “find: paths must precede expression:” How do I specify a recursive search that also finds files in the current directory?
- curl: no URL specified for restful api
- firebase-tools “-bash: firebase: command not found”
- source command not found in sh shell
- Running bash script from within python
- How to run C program on Mac OS X using Terminal?
- Pipe to/from the clipboard in a Bash script
- Bash mkdir and subfolders
- How to get the first line of a file in a bash script?
- Difference between sh and Bash
- What is a simple explanation for how pipes work in Bash?
- How to open Emacs inside Bash
- Error handling in Bash
- bash which OR operator to use – pipe v double pipe
- What does ‘bash -c’ do?
- Timeout a command in bash without unnecessary delay
- How do I know the script file name in a Bash script?
- How to cd into a directory with this name “-2” (starting with the hyphen)?
- Check if array is empty in Bash
- Run an interactive bash subshell with initial commands without returning to the (“super”) shell immediately
- What’s the best way to check if a volume is mounted in a Bash script?
- How do I find the UUID of a filesystem
- Find out symbolic link target via command line
- Clean way to write complex multi-line string to a variable
- Linux command line best practices and tips?
- How to run command as user who has /usr/sbin/nologin as Shell?
- How to get pid of just started process
- How to sort ps output by process start time?
- How to remove invalid characters from filenames?