Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Kunal Verma
Page 2 of 2
Parse Command Line Arguments in Bash on Linux
Command-line arguments are parameters passed to bash scripts that allow users to customize script behavior without modifying the script itself. These arguments can be processed sequentially as positional parameters or parsed as options using built-in utilities like getopts and external tools like getopt. Note − Linux commands are case-sensitive. Basic Command Line Arguments Bash automatically stores command-line arguments in special variables: $0 − Script name $1, $2, $3... − Positional arguments $# − Number of arguments $@ − All arguments as separate strings $* − All arguments as a single string #!/bin/bash ...
Read MoreSkip Hidden Files and Directories During Recursive Copy
Recursive copying is a common task in Linux systems, but sometimes we need to exclude hidden files and directories (dotfiles) during the process. Hidden files in Linux are those that start with a dot (.) and are typically used for configuration files and system data that should remain invisible during normal operations. This tutorial demonstrates various methods to skip hidden files and directories when performing recursive copy operations using different Linux utilities. Note − Linux commands are case-sensitive. Using cp Command with Shell Globbing The standard cp command can be combined with shell globbing patterns to ...
Read MoreTesting Bash Scripts With Bats in Linux
Bash Automated Testing System (BATS) is a testing framework designed specifically for bash scripts. It allows developers to write automated tests for their bash code, ensuring scripts function correctly before deployment and improving code reliability in production environments. BATS provides a structured approach to testing bash scripts similar to testing frameworks available for other programming languages like Python or Java. It uses a simple syntax that makes writing and maintaining tests straightforward for shell script developers. What is BATS? BATS stands for Bash Automated Testing System. It is a TAP-compliant testing framework that runs tests written in ...
Read MoreThe "Oldconfig" Target In The Linux Kernel Makefile
The Linux kernel provides various configuration targets through its Makefile system to help developers and system administrators build customized kernels. The oldconfig target is a crucial configuration option that allows you to update an existing kernel configuration while preserving your previous settings and only prompting for new options introduced in newer kernel versions. Note − Linux commands are case-sensitive. Understanding the Kernel Build System The Linux kernel build system uses a sophisticated Makefile structure to manage the compilation process. The configuration system determines which features, drivers, and subsystems get included in the final kernel image. There are ...
Read MoreGet the Full Path of a File in Linux
Every file and folder in Linux has a path that directs the user to it. This path is required for programs and scripts to locate and access files. There are various ways to locate the path to a file or folder if you need to. We can get a full file path with different commands on a Linux machine. In this tutorial, we'll show you how to obtain a file's complete path in Linux using multiple command-line methods. Understanding File Paths in Linux In Linux, there are two different kinds of paths: absolute and relative. A forward ...
Read MoreDiff a Directory for Only Files of a Specific Type on Linux
In this article, we are going to learn how to diff a directory for only files of a specific type in Linux. This is particularly useful when you need to compare configuration files, source code, or documentation across directories while ignoring irrelevant file types. The diff Command Overview The diff command is a powerful built-in Linux tool that compares files and directories line by line. When comparing directories, it identifies differences in file contents, missing files, and additional files. However, by default, it processes all files, which can be overwhelming in directories with mixed file types. Basic ...
Read MoreHow to check if a File Type Exists in a Directory?
There are times when we need to determine whether a particular file type is present in a directory or not. For instance, we might want to check if a directory contains Python files or C++ source files. Several Linux commands like ls, find, and file can help us accomplish this task efficiently. In this tutorial, we will review multiple approaches to check whether particular file types exist in a directory using wildcard patterns and command-line utilities. Using the ls Command The ls command is one of the most frequently used commands in Linux for listing files and ...
Read MoreRunning a Shell Script on a Remote Machine Through SSH
SSH (Secure Shell) is a network protocol that allows secure remote access to Linux-based machines. It enables users to execute commands and run shell scripts on remote servers without physically accessing them. The SSH protocol encrypts all data transmission between client and server, ensuring secure communication over potentially unsafe networks. What is SSH SSH stands for Secure Shell or Secure Socket Shell. It provides a secure channel for accessing remote servers by encrypting all data transmitted between the client and host. SSH operates on TCP port 22 by default and replaces insecure protocols like Telnet and rlogin. ...
Read MoreWhat Is Double Dot (..) And Single Dot (.) In Linux?
In Linux, the single dot (.) and double dot (..) are special directory references that appear in every directory. The single dot represents the current directory, while the double dot represents the parent directory. These symbols are fundamental for navigation and file operations in the Linux file system. Understanding Single Dot (.) and Double Dot (..) Every directory in Linux contains two special entries that are automatically created by the file system − $ ls -la total 892 drwxr-xr-x 122 tutorial article 48 18 Dec 05:07 . drwxr-xr-x 54 tutorial ...
Read More