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 Satish Kumar
Page 59 of 94
Bash Continue How to Resume a Loop
Bash is a popular command-line interface shell used extensively in Linux and Unix operating systems. One of its most useful features is the ability to execute loops, which automate repetitive tasks. Sometimes you may need to skip certain iterations within a loop or control its flow. This is where the Bash continue statement becomes essential. What is a Bash Loop? A loop is a programming construct that executes a block of code repeatedly. Bash supports several types of loops including for loops (which iterate over a set of values) and while loops (which execute as long as a ...
Read MoreStoring a Command in a Variable in a Shell Script
In shell scripting, you can store a command in a variable to improve code organization and reusability. This technique allows you to define commands once and execute them multiple times throughout your script. Basic Command Storage The basic syntax for storing a command in a variable is − variable_name="command" For example − current_date="date" list_files="ls -la" To execute the stored command, you need to use command substitution or eval − # Using eval (less secure) eval $current_date # Using command substitution (preferred) $($current_date) Storing Commands in ...
Read MoreSplitting Files in Unix Systems
Unix systems are widely recognized for their efficiency and versatility in handling file operations. One of the most common operations is splitting large files into smaller, more manageable chunks. The split command in Unix is specifically designed to achieve this task, allowing users to divide files based on size, line count, or specific delimiters. Split Command Syntax The basic syntax of the split command is as follows: split [OPTION]... [INPUT [PREFIX]] Where [INPUT] specifies the file to be split, [PREFIX] defines the naming pattern for output files (default is 'x'), and [OPTION] provides various ...
Read MoreRun a Script on Startup in Linux
There are several ways to run a script on startup in Linux, depending on your specific distribution and the type of script you are trying to run. Each method has its own advantages and is suitable for different use cases. Methods Overview Method Best For Linux Systems User Level systemd System services, daemons Modern distributions System-wide cron (@reboot) Simple scripts, scheduled tasks All distributions User or system rc.local Quick system scripts Traditional systems System-wide init.d Legacy system services Older distributions System-wide .bashrc/.bash_profile User-specific ...
Read MoreCommon Linux Text Search
Linux provides powerful command-line tools for searching text within files and directories. Text search is an essential skill for system administrators, developers, and users who need to locate specific content across their filesystem. This article explores the most commonly used Linux text search tools and their practical applications. grep − Pattern Matching The grep command is the most fundamental text search tool in Linux. It searches for patterns within files and displays matching lines. Basic Syntax grep [options] pattern [file...] Common Examples Search for "error" in a log file: grep ...
Read MoreBash declare Statement Syntax and Examples
The declare statement is a built-in Bash command that allows you to set attributes for variables and control their behavior. When you declare a variable using declare, you can specify how Bash should treat that variable − whether it's an array, integer, read-only, or has other special properties. Syntax of Declare Statement The basic syntax of the declare statement is straightforward − declare [options] variable=value Where declare is the keyword, [options] are flags that set specific attributes, and variable=value assigns a value to the variable. Common Declare Options Option ...
Read MoreLinux Commands Comparison curl vs wget
Curl and wget are two essential command-line utilities in Linux for downloading files from the internet. While both serve similar purposes, they have distinct features, capabilities, and use cases. Understanding their differences helps you choose the right tool for your specific needs. Overview of curl and wget Both curl and wget are command-line tools designed to retrieve data from the internet, but they differ in their approach and capabilities. Curl is a versatile data transfer tool that supports numerous protocols including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, and many others. It's designed to handle various data formats ...
Read MoreRunning Script or Command as Another User in Linux
There are several ways to run a script or command as another user in Linux. The most common methods are using the su command (switch user), the sudo command (superuser do), and the runuser command. Each approach has different use cases, security implications, and requirements. These commands are essential for system administration tasks where you need to execute operations with different user privileges without logging out and back in as another user. Using su Command The su command allows you to switch to another user's account. The basic syntax is: su [options] [username] ...
Read MoreHow to Fix \"W: Some index files failed to download.\" Error In Ubuntu?
When you are running updates on Ubuntu, you may come across an error message that says "Some index files failed to download". This error occurs when Ubuntu is unable to download the package indexes from the software repositories it relies on for updates. The package indexes contain a list of available packages, their versions, and dependencies. Without these indexes, you cannot update or install new packages on your system. It is important to fix this error as soon as possible because it can cause your system to be vulnerable to security risks and bugs. Additionally, if you do not ...
Read MoreMultiple simultaneous downloads using Wget
When it comes to downloading files from the internet, there are numerous ways to go about it. One such method is using the command-line tool Wget, which is an extremely versatile and powerful utility for downloading files. Wget is a popular tool among developers, system administrators, and even casual users due to its simplicity and speed. In this article, we will take a closer look at Wget's ability to download multiple files simultaneously, and how this feature can improve your download speeds and efficiency. What is Wget? Wget is a command-line utility used for retrieving files from ...
Read More