बैश कमांड में पहले शब्द को त्वरित रूप से कैसे बदलें?

विषयसूची:

बैश कमांड में पहले शब्द को त्वरित रूप से कैसे बदलें?
बैश कमांड में पहले शब्द को त्वरित रूप से कैसे बदलें?

वीडियो: बैश कमांड में पहले शब्द को त्वरित रूप से कैसे बदलें?

वीडियो: बैश कमांड में पहले शब्द को त्वरित रूप से कैसे बदलें?
वीडियो: Minecraft - How To Add Custom Splash Texts! - YouTube 2024, मई
Anonim
यदि आपका वर्कफ़्लो कई बार दोहराए जाने वाले कार्यों के साथ पॉप्युलेट किया गया है, तो यह आपके वर्कफ़्लो को बेहतर बनाने और व्यवस्थित करने के तरीकों की तलाश में कभी दर्द नहीं करता है। आज के सुपर यूज़र क्यू एंड ए पोस्ट में उनके वर्कफ़्लो को बेहतर बनाने के लिए पाठक के लिए कुछ उपयोगी सुझाव हैं।
यदि आपका वर्कफ़्लो कई बार दोहराए जाने वाले कार्यों के साथ पॉप्युलेट किया गया है, तो यह आपके वर्कफ़्लो को बेहतर बनाने और व्यवस्थित करने के तरीकों की तलाश में कभी दर्द नहीं करता है। आज के सुपर यूज़र क्यू एंड ए पोस्ट में उनके वर्कफ़्लो को बेहतर बनाने के लिए पाठक के लिए कुछ उपयोगी सुझाव हैं।

आज का प्रश्न और उत्तर सत्र हमारे पास सुपरयूसर की सौजन्य है - स्टैक एक्सचेंज का एक उपविभाग, क्यू एंड ए वेब साइट्स का एक समुदाय संचालित समूह।

मैट जॉयस (फ़्लिकर) की स्क्रीनशॉट सौजन्य।

प्रश्न

सुपर यूज़र रीडर सिक्का जानना चाहता है कि बैश कमांड में पहले शब्द को जल्दी से कैसे बदला जाए:

I would like to improve my workflow in bash and realized that I often want to execute the same command to a different executable.

Some Examples

1.) Git

2.) Bash
2.) Bash
Image
Image

I know that I can hit Ctrl+a then Del to remove the first word, but I am wondering if there is a quicker way to do it.

क्या सिक्का के लिए बैश कमांड में पहला शब्द बदलने का कोई तेज तरीका है?

उत्तर

सुपरयूसर योगदानकर्ता स्पिफ, हस्तूर, जेजेलिन। और गुस्तावो Giraldez हमारे लिए जवाब है। सबसे पहले, स्पिफ:

!$ expands to the last word of your previous command. So you could do:

Or
Or
Your examples happened to only repeat the last word, so !$ worked fine. If you actually had a lot of arguments that you wanted to repeat, and you just wanted to change the first word, you could use !*, which expands to all words of the previous command except the zeroth.
Your examples happened to only repeat the last word, so !$ worked fine. If you actually had a lot of arguments that you wanted to repeat, and you just wanted to change the first word, you could use !*, which expands to all words of the previous command except the zeroth.

See the “HISTORY EXPANSION” section of the bash man page. There is a lot of flexibility there.

हस्तूर से जवाब का पालन करें:

I would like to add a warning (see the answer from Spiff above). With !$, you do not have full visual control of the line you are running. The results can be harmful sometimes, especially if you incur a misprint. It takes what it needs from the history to expand on.

So if you write the last command with a blank space at the beginning, then this command will probably not finish from the history. When you execute your new command with !$, the shell will not take the parameters from the last command line typed, but only from the last part of the history.

Here are some more helpful words and commands.

फिर jjlin से जवाब:

Ctrl+a to go to the beginning of the line, then Alt+d to delete the first word.

और गुस्तावो Giraldez से हमारा अंतिम जवाब:

The delete word shortcut is actually Meta+d, and Meta is usually mapped to Alt on Linux machines. On platforms where this is not the case, an alternative to get the Meta modifier is to use Esc as a prefix. You can read more about the Meta Key here.

स्पष्टीकरण में जोड़ने के लिए कुछ है? टिप्पणियों में विचार व्यक्त करो। अन्य तकनीक-समझदार स्टैक एक्सचेंज उपयोगकर्ताओं से अधिक उत्तरों पढ़ना चाहते हैं? यहां पूर्ण चर्चा धागा देखें।

सिफारिश की: