• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Juniper Client

Its all about Networks

  • Juniper SRX
  • Juniper eBooks
  • Juniper Switches
    • Juniper Ex Switch
    • Juniper Networks Switches
    • Juniper Switch
  • Juniper Apps
  • News
  • Juniper eBooks
  • About Us
  • Show Search
Hide Search

Tagging instructions on Linux | Community World

vijesh · November 10, 2020 · Leave a Comment


Tags present a simple approach to affiliate strings that appear like hash tags (e.g., #HOME) with instructions that you simply run on the command line. As soon as a tag is established, you’ll be able to rerun the related command with out having to retype it. As a substitute, you merely kind the tag. The concept is to make use of tags which can be simple to recollect for instructions which can be advanced or bothersome to retype.

In contrast to organising an alias, tags are related together with your command historical past. Because of this, they solely stay accessible when you preserve utilizing them. When you cease utilizing a tag, it can slowly disappear out of your command historical past file. After all, for many of us, meaning we will kind 500 or 1,000 instructions earlier than this occurs. So, tags are a great way to rerun instructions which can be going to be helpful for some time frame, however not for those who you need to have accessible completely.

To arrange a tag, kind a command after which add your tag on the finish of it. The tag should begin with a # signal and ought to be adopted instantly by a string of letters. This retains the tag from being handled as a part of the command itself. As a substitute, it is dealt with as a remark however remains to be included in your command historical past file. Here is a quite simple and never significantly helpful instance:

$ echo "I like tags" #TAG

This explicit echo command is now related to #TAG in your command historical past. In case you use the historical past command, you may see it:

$ historical past | grep TAG
  998  08/11/20 08:28:29 echo "I like tags" #TAG     <==
  999  08/11/20 08:28:34 historical past | grep TAG

Afterwards, you’ll be able to rerun the echo command proven by coming into !? adopted by the tag.

$ !? #TAG
echo “I like tags” #TAG
“I like tags”

The purpose is that you’ll doubtless solely need to do that when the command you need to run repeatedly is so advanced that it is onerous to recollect or simply annoying to kind repeatedly. To checklist your most lately up to date information, for instance, you would possibly use a tag #REC (for “latest”) and affiliate it with the suitable ls command. The command beneath lists information in your house listing no matter the place you’re at the moment positioned within the file system, lists them in reverse date order, and shows solely the 5 most lately created or modified information.

$ ls -ltr ~ | tail -5 #REC	<== Affiliate the tag with a command
drwxrwxr-x  2 shs     shs        4096 Oct 26 06:13 PNGs
-rw-rw-r--  1 shs     shs          21 Oct 27 16:26 solutions
-rwx------  1 shs     shs         644 Oct 29 17:29 update_user
-rw-rw-r--  1 shs     shs      242528 Nov  1 15:54 my.log
-rw-rw-r--  1 shs     shs      266296 Nov  5 18:39 political_map.jpg
$ !? #REC			<== Run the command that the tag is related to
ls -ltr ~ | tail -5 #REC
drwxrwxr-x  2 shs     shs        4096 Oct 26 06:13 PNGs
-rw-rw-r--  1 shs     shs          21 Oct 27 16:26 solutions
-rwx------  1 shs     shs         644 Oct 29 17:29 update_user
-rw-rw-r--  1 shs     shs      242528 Nov  1 15:54 my.log
-rw-rw-r--  1 shs     shs      266296 Nov  5 18:39 political_map.jpg

You too can rerun tagged instructions utilizing Ctrl-r (maintain Ctrl key and press the “r” key) after which typing your tag (e.g., #REC). The truth is, in case you are solely utilizing one tag, simply typing # after Ctrl-r ought to carry it up for you. The Ctrl-r sequence, like !?, searches via your command historical past for the string that you simply enter.

Tagging areas

Some folks use tags to recollect explicit file system areas, making it simpler to return to directories they”re working in with out having to kind full listing paths.

$ cd /apps/knowledge/stats/2020/11 #NOV
$ cat stats
$ cd !? #NOV <== takes you again to /apps/knowledge/stats/2020/11

After utilizing the #NOV tag as proven, every time it’s essential transfer into the listing related to #NOV, you’ve got a fast means to take action – and one that does not require that you simply suppose an excessive amount of about the place the information information are saved.

NOTE: Tags do not should be in all uppercase letters, although this makes them simpler to acknowledge and unlikely to battle with any instructions or file names which can be additionally in your command historical past.

Options to tags

Whereas tags will be very helpful, there are different methods to do the identical issues that you are able to do with them.

To make instructions simply repeatable, assign them to aliases.

$ alias latest=”ls -ltr ~ | tail -5”

To make a number of instructions simply repeatable, flip them right into a script.

#!/bin/bash
echo “Most lately up to date information:”
ls -ltr ~ | tail -5

To make file system areas simpler to navigate to, create symbolic hyperlinks.

$ ln -s /apps/knowledge/stats/2020/11 NOV

To rerun lately used instructions, use the up arrow key to again up via your command historical past till you attain the command you need to reuse after which press the enter key.

You too can rerun latest instructions by typing one thing like “historical past | tail -20” after which kind “!” following by the quantity to the left of the command you need to rerun (e.g., !999).

Wrap-up

Tags are most helpful when it’s essential run advanced instructions many times in a restricted timeframe. They’re simple to arrange they usually fade away if you cease utilizing them.

Be part of the Community World communities on Fb and LinkedIn to touch upon subjects which can be prime of thoughts.

Copyright © 2020 IDG Communications, Inc.

Filed Under: News

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Juniper targets data-center automation with Apstra replace

Telemetry steps into the enterprise-networking highlight

Don’t Await a Refresh to Obtain a Fashionable Community

Cut back the Community Crew’s Workload with AI Applied sciences

Eight sizzling networking applied sciences for 2023

Received Community Downtime? Right here’s How you can Proactively Scale back It

IT Leaders Have a Inexperienced Alternative to Help Sustainability

Cloud suppliers ought to unify digital networking and SD-WAN

IT provide points have organizations shifting from just-in-time to just-in-case shopping for

Information middle networking developments to observe for 2023

Seize AI-driven Alternatives to Clear up Hybrid Work Challenges

How AI, Automation, and Zero Belief Can Enhance Enterprise Networks

For Searching IFSC Codes in Banks Visit Here

For Biographies visit Crazum.com

Footer

About Juniper Client

Juniper Client is a blog dedicated in solving juniper related problems like juniper srx load balancing, juniper routers, juniper switches etc. Juniper Client is the premier provider of information, intelligence and insight for Juniper Network and IT Executives. Our main focus is to deliver news, opinion and networking tools for managing business solutions. We offer a unique and valuable information for businesses to meet their marketing objectives. Read More...

FIND IT HERE

Copyright © 2023 · Daily Dish Pro on Genesis Framework · WordPress · Log in