Home » 2021

How to Count Files in a Directory in Linux/Ubuntu

Linux Count Files in Directory

This tutorial will show you how to count the number of files/folders in a directory on Linux, both recursively and non-recursively. The wc Command The wc (word count) command counts lines and words. It’s useful here as we’ll use it to count the outputted lines from various tools which list the files in a directory or directories. The below examples will show you how to use the wc command to count files. If you want to know more about it, you can check out the full user manual by running: man … Read more

Home » 2021

How to use the JavaScript trim Method, with Examples

JavaScript trim

This easy tutorial will show you how to use the JavaScript string trim() method and give some example usage. The trim()* method is available to any string type variable in JavaScript. It removes any white space (spaces, tabs, newlines) found at the beginning and the end of the string. Why is this useful? Sometimes you wind up with a bunch of un-needed white space padding your strings – often from the end-user hammering the space key when a space isn’t required. Unnecessary white space can also occur after splitting … Read more

Home » 2021

How to Get the Last Item in a JavaScript Array [Quick Tip]

JavaScript - Get last item in array

This quick article will show you how to get the last item in an array in the JavaScript programming language. Arrays and Array Indexes in JavaScript Arrays are an ordered list of items. Each item in the array has a numerical index that defines its permission in the array. The first index is index 0 (indexes start counting at 0, not 1!), so the last index is the array’s length; subtract 1. Getting the Last Item in an Array So, to get the last item in an array, we just … Read more

Home » 2021

How to Filter Arrays in JavaScript, With Examples

Javascript: filter arrays

We’ve covered arrays in JavaScript pretty extensively on LinuxScrew. This article will show you how to use the filter method – with easy-to-follow examples. JavaScript Arrays Arrays are a type of variable that holds a list of other values or variables. They’re one of the fundamentals of computer programming. These lists contain items at positions (called indexes). These items can be anything – numbers, strings, complex objects – whatever you want to store. Arrays are super useful. You might use them to store the rows in a … Read more

Home » 2021

How to Get the Length of an Array in JavaScript [Examples]

JavaScript Array Length

This article will show you how to get the length of an array in JavaScript, as well as provide some code examples. JavaScript is one of the most popular programming languages. From humble origins as a webpage scripting language for animating menus and displaying pop-up ads, it is now a full-blown ecosystem that you can use to build cross-platform mobile apps, web pages, server processes, and even games. JavaScript Arrays Arrays are a vital building block for any program, even simple ones. An array is a … Read more

Home » 2021

How to Use the watch Command in Linux, With Examples

Linux watch command

The watch command in Linux does one thing – repeats a command and outputs the result repeatedly, letting you watch for changes. Here’s how to use it. watch Command Syntax The syntax for the watch command is as follows: watch OPTIONS COMMAND Note that: OPTIONS should be a list of options from the below table, which will alter the default behavior of the watch command COMMAND is the command that watch should repeatedly execute, which you will monitor the output of watch will run until interrupted (So press CTRL+C to exit … Read more

Home » 2021

How to Install PowerShell in Linux/Ubuntu

Install Powershell in Linux

This easy-to-follow tutorial shows you how to install PowerShell on a variety of Linux systems. What is PowerShell? Like Linux has Bash, Zsh, and other interactive shells for issuing commands to the system via the terminal, Windows has PowerShell. It’s the successor to the Windows Command Prompt. It allows the user to type commands for execution and provides features for automation and scripting. And now, it runs on Linux. This is useful if you administer Windows servers remotely or interact with Microsoft’s Azure Cloud services. Certain tasks in Office 365 … Read more

Home » 2021

The Best, Easiest Way to Check Linux Memory Usage

Linux Memory Usage

Here are the quickest and easiest methods to check memory usage on your Linux system. If you find your home Linux machine is a bit sluggish or your web server keeps hanging, it’s worth checking whether anything is hogging your memory. It may be that a poorly-coded page is using up a disproportionate amount of system resources, or it may be that your computer or server doesn’t have enough RAM for the task assigned to it. Either way, these useful tools will help you diagnose … Read more

Home » 2021

Creating and Writing Floppy Disk Images in Linux with dd

Linux dd read write floppy images

This article will show you how to read and write images to floppy disks in Linux – Perfect for vintage computing (MS-DOS, Macintosh, etc.) I dabble a bit in vintage computing – finding old computers, fixing them up, and getting them back into action – usually for playing games on era-appropriate hardware. Part of this usually involves re-installing the operating system and loading up software. This used to be pretty simple – when Windows computers came with floppy disk drives and included the required tools, it … Read more

Home » 2021

Bash/Shell Script to Send Email In Linux – Howto, Example

Sending Emails from Bash/Command Line

This article will show you several ways to send an email from the Linux command line/shell – as well as from Bash/Shell scripts. Why would you want to send an email from the command line? Probably not to communicate – most people use an email client with a nice user interface to send messages to each other day to day – but you may want to have your computer send an email notification when a task completes or when an event occurs. Such email alerts … Read more