Quickly Tag Complex Linux Commands for Instant Recall
This guide shows how to label lengthy Linux commands with custom tags and use the !? operator or shell aliases to retrieve and execute them instantly, providing two practical techniques for simplifying command-line workflows.
Tagging Linux Commands
Linux commands can become long and hard to remember; adding a short tag at the end lets you recall the command later by typing the tag instead of the full command line.
find . -size +10M -type f -print0 | xargs -0 ls -Ssh | sort -z #ListFilesBiggerThanXSizeNote that the tag must start with # and be separated from the command by a space.
To run the tagged command, use the !? operator followed by the tag:
[alvin@VM_0_16_centos ~]$ !? #ListFilesBiggerThanXSize
find . -size +10M -type f -print0 | xargs -0 ls -Ssh | sort -z #ListFilesBiggerThanXSizeAnother Method: Using alias
You can achieve the same effect by creating a shell alias that stores the long command under a short name.
alias ListFilesBiggerThanXSize='find . -size +10M -type f -print0 | xargs -0 ls -Ssh | sort -z'Invoke the command simply by typing the alias name: ListFilesBiggerThanXSize Both techniques let you avoid re‑typing complex commands and improve productivity on the Linux command line.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
