Useful Example for the mv command in Linux

mv Command Examples
Below is the basic mv command examples on Linux terminal.

  • Rename file in current directory – For example rename file source.txt to dest.txt in current directory.
  • Move file to destination directory – Move a source.txt file available in current directory to /tmp directory. In above command the file name is unchanged at target directory. You can also rename file name at destination directory just by providing filename at destination.
  • Move file from source directory to destination directory – We can also move files or directory from some other directory to destination directory.
  • Move multiple files to destination at once – The mv accepts multiple source files and move them to the destination directory at once. The following command will move file1.txt, file2.txt in current directory and /opt/file3.txt to the /tmp directory. Here the last command line parameter is used as destination by the mv command.

#linux commands #command #mv #useful example #mv command #linux

Examples of the dig command in Linux

Dig Command Line Options and Examples
Here is the frequently used command line options and example’s of dig command.
1. Basic Dig Command
A basic dig command accept domain name as command line parameter and prints Address record.
2. Query With Specific DNS Server
The default dig command queries to dns server configured on your system. For example, the Linux systems keep default DNS entry in /etc/resolv.conf.
3. Print Short Answer
Use +short command line option to print result in short form. This is basically useful with the shell scripting and other automation tasks.
4. Print Detailed but Specific Result
Use +noall with +answer to print detailed information but specific. This will print only answer section including few more details as a result.

#linux commands #command #dig #dig command #useful examples #linux

Mertie  Feil

Mertie Feil

1597673460

gpm Command in Linux with Examples

GPM (“General Purpose Mouse”) software provides support for mouse devices in Linux virtual consoles. This package provides a daemon that captures mouse events when the system console is active and delivers events to applications through a library. By default, the daemon provides a ‘selection’ mode, in order that cut-and-paste with the mouse works on the console even as it does under X. It is used to select the text, drag the mouse while holding the left button, or to paste text within the same or another console, press the center button. The right button is employed to increase the choice. Two-button mice use the right button to paste the text.

Installation:

It is included in most Linux distributions, but in case it is not, then run this command to install gpm.

sudo apt-get install gpm

Syntax:

sudo gpm [options]

#linux-unix #linux-command #linux-system-commands #picked

I am Developer

1620616862

How to Delete Directories and Files in Linux using Command Line

In this remove or delete directories and files linux tutorial guide, you will learn how to remove empty directory and non empty directory linux using command line. And as well as how to remove/file files linux using command line.

If you work with Linux then you will need the following:

  • how to remove empty directory in linux,
  • how to remove non empty directory,
  • how to remove directory without confirmation linux
  • how to remove files with and without confirmation in linux.

So, this tutorial guide will show you you how to use the rmunlink, and rmdir commands to remove or delete files and directories in Linux with and without confirmation.

https://www.tutsmake.com/how-to-remove-directories-and-files-using-linux-command-line/

#how to delete directory in linux #how to remove non empty directory in linux #remove all files in a directory linux #linux delete all files in current directory #linux delete all files in a directory recursively #delete all files in a directory linux

Maud  Rosenbaum

Maud Rosenbaum

1597289640

5 Best CLI Tools to Search Plain-Text Data Using Regular Expressions

This guide takes a tour of some of the best command-line tools that are used for searching matching strings or patterns in text files. These tools are usually used alongside regular expressions – shortened as REGEX – which are unique strings for describing a search pattern.

Without much further ado, let’s dive in.

1. Grep Command

Coming in the first place is the grep utility tool – is an acronym for Global Regular Expression Print, is a powerful command-line tool that comes in handy when searching for a specific string or a pattern in a file.

Grep ships with modern Linux distributions by default and gives you the flexibility to return various search results. With grep, you can perform a vast array of functioning such as:

  • Search for strings or matching patterns in a file.
  • Search for strings or matching patterns in Gzipped files.
  • Count the number of string matches.
  • Print the line numbers that contain the string or pattern.
  • Search recursively for the string in directories.
  • Perform a reverse search ( i.e. Display results of strings not matching the search criteria).
  • Ignore case sensitivity when searching for strings.

The syntax for using the grep command is quite simple:

$ grep pattern FILE

For example, to search for the string ‘Linux‘ in a file, say, hello.txt while ignoring case sensitivity, run the command:

$ grep -i Linux hello.txt

Search For String in a File

Search For String in a File

To get more options that you can use with grep, simply read our article that examples more advanced grep command examples.

2. sed Command

Sed – short for Stream Editor – is another useful command-line tool for manipulation text in a text file. Sed searches, filters and replaces strings in a given file in a non-interactive manner.

By default, sed command prints the output to STDOUT (Standard Out), implying that the result of the execution is printed on the terminal instead of being saved in a file.

Sed command is invoked as follows:

$ sed -OPTIONS command [ file to be edited ]

For example, to replace all instances of ‘Unix‘ with ‘Linux‘, invoke the command:

$ sed 's/Unix/Linux' hello.txt

Replace String in a File

Replace String in a File

If you want to redirect output instead of printing it on the terminal, use the redirection sign ( > ) as shown.

$ sed 's/Unix/Linux' hello.txt > output.txt

Redirect Output to File

Redirect Output to File

The output of the command is saved to the output.txt file instead of being printed on the screen.

To check out more options that can be used, once again check out the man pages.

$ man sed

3. Ack Command

Ack is a fast and portable command-line tool written in Perl. Ack is considered a friendly replacement for grep utility and outputs results in a visually appealing manner.

Ack command searches the file or directory for the lines that contain the match for the search criteria. It then highlights the matching string in the lines.

Ack has the capacity to distinguish files based on their file extensions, and to a certain extent, the content in the files.

Ack command syntax:

$ ack [options] PATTERN [FILE...]
$ ack -f [options] [DIRECTORY...]

For example, to check for the search term Linux, run:

$ ack Linux hello.txt

Check a String in a File

Check a String in a File

The search tool is quite intelligent and If no file or directory is provided by the user, it searches the current directory and subdirectories for the search pattern.

In the example below, no file or directory has been provided, but ack has automatically detected the available file and searched for the matching pattern provided.

$ ack Linux

Search String in a Directory

Search String in a Directory

To install ack on your system run the command:

$ sudo apt install ack-grep    [On Debian/Ubuntu]
$ sudo dnf install ack-grep    [On CentOS/RHEL]

#awk command #linux commands #sed command #commandline tools #linux tricks #linux