Try to create a new command on linux

--This is a volume to try to create a new command on linux.

What does the new command mean? You can create a " newfile.txt " file by typing the newfile command.

――How does it work?

Use the alias command.

  1. Type the newfile command
  2. Run touch newfile.txt behind the scenes
  3. I am creating a " newfile.txt " file.

--Registration command

alias Alias command='command'

--Delete command

unalias alias command

Register the command

※Caution

Please note that alias is reset when you close the terminal screen or log out.

Temporarily register

--Registration

alias newfile='touch newfile.txt'

--Registration confirmation

$ alias | grep newfile
==========
alias newfile='touch newfile.txt'
==========

I was able to register!

--Execute

$ ls
(Nothing was returned)

$ newfile

$ ls
newfile.txt

newfile.txt was done!

Permanently registered

--Registration

vi  ~/.bashrc
==========
add to
alias newfile='touch newfile.txt'
==========

--Login again

exit

--Registration confirmation

$ alias | grep newfile
==========
alias newfile='touch newfile.txt'
==========

I was able to register!

--Execute

$ ls
(Nothing was returned)

$ newfile

$ ls
newfile.txt

newfile.txt was done!

Delete the command

Deletion when registered temporarily

--Registration confirmation

$ alias | grep newfile
==========
alias newfile='touch newfile.txt'
==========
unalias newfile

--Confirmation of deletion

$ alias | grep newfile
(Nothing is returned)

Temporary deletion when registered permanently

--Registration confirmation

$ alias | grep newfile
==========
alias newfile='touch newfile.txt'
==========

--Temporary deletion

unalias newfile

--Confirmation of deletion

$ alias | grep newfile
(Nothing is returned)

Permanent deletion when registered permanently

--Registration confirmation

$ alias | grep newfile
==========
alias newfile='touch newfile.txt'
==========
vi  ~/.bashrc
==========
Delete
alias newfile='touch newfile.txt'
==========

--Login again

exit

--Confirmation of deletion

$ alias | grep newfile
(Nothing is returned)

reference

-You can also create new commands! Alias command detailed summary [Linux command collection] -Command alias reintroduction to make commands convenient

Recommended Posts

Try to create a new command on linux
[C language] [Linux] Try to create a simple Linux command * Just add! !!
How to create a shortcut command for LINUX
Command to create Linux Live USB
Create a Linux environment on Windows 10
[Linux convenient command] Try to insert vivid
Create a Linux virtual machine on Windows
[Cloudian # 3] Try to create a new object storage bucket with Python (boto3)
Create a command to encode / decode Splunk base64
Use click to create a sub-sub command --netsted sub-sub command -
Try NeosVR on Linux
Create a command to get the work log
One-liner to create a large number of test files at once on Linux
Try to dynamically create a Checkbutton with Python's Tkinter
Yum command to access MySQL with Python 3 on Linux
How to install Linux on a 32bit UEFI PC
How to create a local repository for Linux OS
How to build a Python environment on amazon linux 2
A super introduction to Linux
Create command shortcuts on Ubuntu 16.04
Easy df command on Linux
Create a classroom on Jupyterhub
linux: create original Terminal command
Try to select a language
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
[Go language] Try to create a uselessly multi-threaded line counter
Create a new csv with pandas based on the local csv
A memo on how to easily prepare a Linux exercise environment
How to build a new python virtual environment on Ubuntu
Create a VS Code + Docker development environment on a Linux VM
How to create an ISO file (CD image) on Linux
When you want to hit a UNIX command on Python
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
How to display a specified line of a file or command result on Linux (sed, awk)
[Linux convenient command] Try inserting exa
Easy copy to clipboard on Linux
Try to draw a Bezier curve
Steps to create a Django project
A memorandum to change to Manjaro Linux
Create a Python environment on Mac (2017/4)
Install Arch Linux on DeskMini A300
How to create a Conda package
Completion of docker command on Linux
[Linux convenient command] Try inserting csview
Run a Linux server on GCP
How to install VMware-Tools on Linux
How to create a virtual bridge
Create a SlackBot service on Pepper
[linux] kill command to kill the process
[Linux convenient command] Try inserting bat
How to create a Dockerfile (basic)
5 Ways to Create a Python Chatbot
How to create a config file
I tried to create a server environment that runs on Windows 10
[MariaDB] Install MariaDB on Linux and create a DB and an operating user.
I tried to create an environment of MkDocs on Amazon Linux
Try to create a python environment with Visual Studio Code & WSL
A note I was addicted to when making a beep on Linux
Rails users try to create a simple blog engine with Django
Try to edit a new image using the trained StyleGAN2 model
[Go] Create a CLI command to change the extension of the image