6 trucchi intelligenti da riga di comando per ridurre i tasti premuti

I comandi di Linux offrono molta flessibilità. In questo post, approfitterò di alcuni trucchi intelligenti ed elaborerò alcuni modi per renderli ancora più facili da usare.

Usa completamento nome file

Inserendo l’inizio del nome del file e premendo il tasto Tab si elimina la necessità di inserire il nome completo del file. Se la stringa identifica il file in modo univoco, questa operazione completa il nome del file. Altrimenti, puoi inserire un altro carattere nel nome e premere nuovamente Tab. Tuttavia, puoi anche inserire una stringa e quindi premere il tasto Tab due volte per ottenere un elenco di tutti i file che iniziano con una determinata stringa. In questo esempio, facciamo entrambi:

$ ls di<tab><tab>

Reissuing recently used commands is easy bash.. To rerun the previous command, simply type: !! At the command line. You can also make changes and reissue the command.If you issued the first command shown below, just to find it sshd If was not running, you can start by issuing a second command. Just replace “status” with “start”.

sudo systemctl status sshd

You can also reuse only the arguments specified in the previous command without having to retype them using a string. !! * As shown in this example:

$ mkdir dir1 dir2 dir3

Note that if you enter a command using “! *”, The command will be displayed in full.

Note that “all arguments” actually means “all arguments”.To list the directories created using after entering the above command !! * The trick, you will run into a small problem.

$ ls -ld !*
ls -ld 770 dir1 dir2 dir3

The路 history You can easily see the commands you entered earlier using command, but it usually displays 1000 (that is, all) commands in the history buffer.If you want to see only For recently entered commands, the easiest and fastest way is to specify the number of commands to display as arguments. history command. This list shows the five most recent commands entered.

$ history 5

You can also use a command like “history | tail -5”, but the one just shown is easier and you don’t have to send 1000 lines of output to. tail command.

Find the history of a particular command and re-execute

To look back at the most recently used command (first to last) to rerun a particular command, type: ^ r (Press Ctrl + r). Then enter part of the command.Hold down ^ r Press Return until you see the command you want to reuse.

(reverse-i-search)`opt': shopt | wc -l

The output shown is shop The command has 53 settings.

Makes file backup very easy

One of the most convenient ways to back up a file is to use a command like the following to add “.backup” to the backup file.

$ cp myfile{,.backup}

The same technique mv Instead, run the command to rename the file.

$ mv myfile{,.backup}

If you want to back up a set of files, you can save a little time and effort by using a script like this:

#!/bin/bash

The following script gets the list of files specified as arguments and copies each to a * .backup form. You can change “backup” to “old” or other words as needed.

$ backup thisfile thatfile otherfile

You can also use wildcards, depending on the name of the file you want to back up. For example:

$ backup project*

I’ve loved the Linux command line since I first used it nearly 40 years ago. And what’s the best part? There is always a lot to learn and how to make it even easier to use!

Join the Network World community above Facebook And LinkedIn Comment on topics that come to mind.

Copyright 漏 2021 IDG Communications, Inc.

Privacy-focused cloud analytics platform Ariadne Maps raises 鈧 2 million Strong passwords alone may not be enough to resolve all security issues Activation and activation of e-Mobility with elastomers New iMac 27-inch with ProMotion display for the first quarter of 2022 Considering manufacturing E2W in India and exporting to US and Europe Dao EV Tech: Report Latest Technology News
    La piattaforma di analisi cloud incentrata sulla privacy Ariadne Maps raccoglie 鈧 2 milioni Le password complesse da sole potrebbero non essere sufficienti per risolvere tutti i problemi di sicurezza Attivazione e attivazione dell’e-Mobility con elastomeri Nuovo iMac 27 pollici con display ProMotion per il primo trimestre del 2022 Considerando la produzione E2W in India ed esportando negli Stati Uniti e in Europa Dao EV Tech: Report

Leave a Reply