TIL: Editing commands from bash history before execution

After years of copy-pasting from `history | grep`, I just learned:

fc 945
→ Opens command #945 in $EDITOR
→ Edit as needed
→ Auto-executes on save

Quick alternative:
!945:p (print command)
↑ (recall and edit)

Or for lighter editor:
fc -e - 945

The fc approach is perfect for complex multi-line edits. The !945:p method is faster for single-parameter changes since you stay in the shell.

#Linux #DevOps #SRE #TIL #BashTips

New Episode: hpr4088 :: Today I Learnt more Bash tips

Hosted by Some Guy On The Internet on 2024-04-03 is flagged as Clean and is released under a CC-BY-SA license.

Tags: #BashTips, TTIL, #getopts.

https://hackerpublicradio.org/eps/hpr4088/index.html

Hacker Public Radio ~ The Technology Community Podcast

Hacker Public Radio is a podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that is of interest to hackers and hobbyists.

Personalize Your BASH Prompt in Linux: Add Colors and Styles to Beautify Your Command Prompt #Bash #BashPrompt #Bashtips #Shell #Linuxshell #Linuxhowto #Linuxtips #Linux
https://ostechnix.com/how-to-customize-bash-prompt-in-linux/
How To Customize Bash Prompt In Linux - OSTechNix

In this guide, we are going to change and customize BASH prompt and enhance its look by adding some colors and styles in a Linux system.

OSTechNix
Rename Files Without Typing Full Name Twice In Linux - OSTechNix

In this brief guide, we will discuss about a simple BASH function to rename files without typing full name twice in Linux operating systems.

OSTechNix

Bash tip of the day. I always forget things like this! If you want to create a folder with a range of numbers after the title:

mkdir test{1..10}

#linux #bashtips #bash #zsh

arden as a service

cli magic 2. now with more operators, and some made-up magic rules. pdf version available here.

Tumblr

sneak peek of my next bash cutesheet.

#bashtips #cutekeyboardclub

[Bash Tips] How To cd and ls in one command - OSTechNix

Here is a BASH function to combine cd and ls in one command. It allows us to list directory contents automatically whenever you cd into it.

Switch To A Directory Without Using Cd Command in Linux - OSTechNix

This guide describes a simple bash trick that helps you to automatically switch to a directory without using cd command in Linux.

How To Repeat A Command Until It Succeeds In Linux - OSTechNix

In this guide, we are going to learn how to repeat a command until it succeeds in Linux using BASH loops such as While loop and Until loop.