If you want to create a fine and write to it in a single command you can do it in various ways, one of the way is to use the echo command and use > redirect the text to a file, but doing so the file will be created and echoed text will be written to the file.
Example:
bash $ echo "This will be written to the file" > myFile.txt
bash $ cat myFile.txt
This will be written to the file

You can in this way also redirect the output of a command to a file.
Example:bash-3.2$ cd /
bash-3.2$ ls > /Users/code2care/Desktop/myFile.txt
bash-3.2$ cat /Users/code2care/Desktop/myFile.txt
Applications
Library
System
Users
Volumes
bin
cores
dev
etc
home
opt
private
sbin
tmp
usr
var
Comments:
- Thanks!
03 Jul 2022 17:07:05 GMT
- Further comments disabled!
More Posts related to Linux,
- [Fix] Linux - bash: useradd: command not found
- Calculate days between dates using dateutils ddiff command
- pwd Command - Print Working Directory
- Rename a directory using Linux/Unix command
- How to go to the End of File in Nano Editor
- How to tar.gz a directory or folder Command
- How to remove/delete a directory in Linux/macOs
- How to Display content of a file in Terminal Screen?
- ls command sort by file size [Linix/UNIX/macOS/bash]
- How to Copy Entire Directory to another Directory in Linux
- 3 ways to clear screen on Linux Terminal
- Command to check Last Login or Reboot History of Users and TTYs
- How to check uptime of Linux/Unix/macOS system/server using console command?
- How to backup a file in Linux/Unix
- Command to know the installed Debian version?
- Check SSH/OpenSSH version Command
- 3 Commands to stop Nginx Server
- Linux: Create a New User and Password and Login Example
- How to install npm on Ubuntu
- How to List All Users in Linux
- How to Get the List of Shells on Linux
- Fix - ssh-copy-id no identities found error
- Installing and using unzip Command to unzip a zip file using Terminal
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- zsh hello world example
More Posts:
- AlertDialog with single button example : Android - Android
- How to Enable Dark Mode Theme in Microsoft Teams - Teams
- Notepad++ select all above or below lines - NotepadPlusPlus
- How to fix: Please check your network connection (Retry) - HowTos
- JDBC SQLException Statement.executeQuery() cannot issue statements that do not produce result sets - Java
- How to See Hidden Folders and Files on macOS - Mac-OS-X
- How to install homebrew (brew) on M1 Mac - MacOS
- Run JumpCloud Commands in Powershell - Powershell