Explore a few techniques for obtaining unique values from an ArrayList in Java.
Baeldung Author
Kai Yuan
Kai Yuan has been a software developer for over 15 years. He builds enterprise Java applications in work. He has 20 years experience of Linux and is a big fan of the Vim editor. He is happy to help people at stackoverflow.com. He lives currently in Hamburg.
Here's what I've written (so far):
Baeldung on Java
- All
- Java (52)
- Java Collections (25)
- Programming (6)
- Maven (3)
- Testing (2)
- Spring Boot (2)
- Persistence (2)
- Java Concurrency (2)
- XML (1)
- REST (1)
- Jackson (1)
- JSON (1)
- IDE (1)
Converting Map<String, Object> to Map<String, String> in Java
Filed under Java Collections
Learn different ways to convert a Map to Map.
Disable Wildcard Import in IntelliJ
Filed under IDE
Learn how to set three main configuration options to disable wildcard imports in Java files in IntelliJ.
Set Default Value for Elements in List
Filed under Java Collections
Explore various approaches to initialize a Java List with default values.
Write Console Output to Text File in Java
Filed under Java
Lern how to make System.out.println() print data to a file by replacing the default System.out
How to Take Input as String With Spaces in Java Using Scanner?
Filed under Java
Learn how to read values containing spaces from a Scanner through examples.
Convert an OutputStream to an InputStream
Filed under Java
Explore two approaches to converting an OutputStream to an InputStream: using a byte array and a pipe.
Storing Java Scanner Input in an Array
Filed under Java
Learn how to store the input from a Scanner into an array with three different scenarios and examples.
Comparing Two Byte Arrays in Java
Filed under Java Collections
Learn common pitfalls when comparing the contents of two arrays and explore the correct way to compare two byte arrays.
Remove Punctuation From a String in Java
Filed under Java
Learn how to remove punctuation from a string using the standard String.replaceAll() method.
Print “” Quotes Around a String in Java
Filed under Java
Explore three different approaches to printing a string with quotes (“) around it.
Difference Between Java’s “char” and “String”
Filed under Java
Learn the differences between char and String in Java.
Find the Most Frequent Characters in a String
Filed under Java
Learn three approaches to finding the most frequent characters in a string, with examples.
Getting the Text That Follows After the Regex Match in Java
Filed under Java
Learn two variations on the problem of extracting text that follows after a regex match and how to do it using Java.
Integer.parseInt(scanner.nextLine()) and scanner.nextInt() in Java
Filed under Java
Learn the differences between Integer.parseInt(Scanner.nextLine()) and Scanner.nextInt() through examples.
Generate the Same UUID From a String in Java
Filed under Java
Learn how to generate the same UUID objects from a string.
Convert Boolean to String in Java
Filed under Java
Explore various ways of converting boolean values to strings.
Convert a Number to a Letter in Java
Filed under Programming
Learn a few ways of converting an integer to an English letter.
Can Stream.collect() Return the null Value?
Filed under Java Collections
Learn whether Java’s Stream.collect() can return null.
Handle Duplicate Keys When Producing Map Using Java Stream
Filed under Java Collections
Explore two approaches to handling duplicated keys when producing a Map result using Stream API.
Combining Two Lists Into a Map in Java
Filed under Java Collections
Learn three ways to combine two given lists into a map through examples
Check if Object Is an Array in Java
Filed under Java Collections
Learn two ways to check if a given object is an array.
Understanding the Difference Between Stream.of() and IntStream.range()
Filed under Java
Learn about Stream.of() and IntStream.range() and learn about certain operations that may turn a Stream from “lazy” to “eager”.
Single Assert Call for Multiple Properties in Java Unit Testing
Filed under Testing
Learn three approaches to verifying multiple properties in one assert call using JUnit5 and AsssertJ.
Return Absolute Difference of Two Integers in Java
Filed under Java
Explore calculating the absolute difference between two integers.
Check if an Integer Value Is Null or Zero in Java
Filed under Java
Learn a few different ways to check if a given Integer instance’s value is null or zero.
Comparing a String to an Enum Value in Java
Filed under Java
Learn how to compare a String to an enum constant through examples.
Multiply a BigDecimal by an Integer in Java
Filed under Java
Learn a few ways to multiply BigDecimal by an Integer.
Storing Data Triple in a List in Java
Filed under Java Collections
Explore how to store triples in a list with examples.
Case-Insensitive Searching in ArrayList
Filed under Java Collections
Learn three approaches to perform case-insensitive searching in ArrayList.
Getting Class Type From a String in Java
Filed under Java
Learn how to use the Class.forName() method to obtain the Class object.
Converting a String Array Into an int Array in Java
Filed under Java Collections
Learn two ways to convert a string array to an integer array through examples
Extracting JAR to a Specified Directory
Filed under Java
Learn two approaches to extracting a JAR file to a specified directory
Convert a List of Integers to a List of Strings
Filed under Java Collections
Learn three ways to convert a list of integers to a list of strings in Java.
Filling a List With All Enum Values in Java
Filed under Java Collections
Learn three approaches to get a List object that contains all instances of an enum
Slicing Arrays in Java
Filed under Java Collections
Learn how to get a subarray of a given array in Java
Difference Between URI.create() and new URI()
Filed under REST
Learn the difference between instantiating a URI object using the constructor and the URI.create() method.
Fixing the “java: integer number too large” Error
Filed under Java
Learn two common pitfalls when we work with integer literals in Java.
Convert String to String Array
Filed under Java Collections
Explore how to convert a String into a String array (String[])
Convert String to char in Java
Filed under Java
Learn how to convert a String to a char in Java.
Capitalize the First Letter of a String in Java
Filed under Java
Learn how to convert a given string’s first character to upper case.
Using Streams to Collect Into a TreeSet
Filed under Java Collections
Explore how to collect elements in a Stream into a TreeSet.
Initializing a Boolean Array in Java
Filed under Java Collections
Learn how to initialize a boolean or Boolean array in Java.
Getting the Filename From a String Containing an Absolute File Path
Filed under Java
Learn how to extract the filename from an absolute path using core Java and Apache Commons.
Make Division of Two Integers Result in a Float
Filed under Java
Learn why the division of integers results in integers and how to get a float result.
Remove the Last Character of a Java StringBuilder
Filed under Java
Learn multiple ways to remove the last character from a StringBuilder sequence
List All Factors of a Number in Java
Filed under Java
Learn how to find all factors of an integer using Java.
Armstrong Numbers in Java
Filed under Java
Learn how to check if an integer is an Armstrong number and generate OEIS sequence A005188 up to a given limit
Toggle a Boolean Variable in Java
Filed under Java
Learn how to build a null-safe method to toggle a given boolean variable in Java
Check if a Number Is Positive or Negative in Java
Filed under Java
We’ll discuss a few ways to solve a simple problem: how to check whether a given number is positive or negative in Java
Named Placeholders in String Formatting
Filed under Java
Learn how to replace parameters in template-based strings from a set of values
Arrays.asList() vs Collections.singletonList()
Filed under Java Collections
Learn about the Arrays.asList() method and the Collections.singletonList() method
Remove Whitespace From a String in Java
Filed under Java
Explore common scenarios of removing whitespace from a String in Java
Get the Full Path of a JAR File From a Class
Filed under Java
Explore how to find the JAR file and its full path from a given class
Check if at Least Two Out of Three Booleans Are True in Java
Filed under Java
Explore a few different approaches to check if there are at least two trues in three given booleans
Check if BigDecimal Value Is Zero
Filed under Java
Explore how to check if a BigDecimal object’s value is zero and learn a common pitfall
Reverse an ArrayList in Java
Filed under Java Collections
Learn how to reverse an ArrayList through examples
Remove File From Git Repository Without Deleting It Locally
Filed under Programming
Learn how to remove a file or directory from a Git repository but keep its local copy
How to Get the Current Branch Name in Git
Filed under Programming
Learn how to get the Git branch name we’re currently working on
Delete a Git Branch Locally and Remotely
Filed under Programming
Learn how to delete Git branches
Move Existing, Uncommitted Work to a New Branch in Git
Filed under Programming
Learn a couple of quick ways to move uncommitted changes to a new Git branch
Working With a List of Lists in Java
Filed under Java Collections
Take a closer look at the Java List of Lists data structure and explore some everyday operations
Convert Byte Size Into a Human-Readable Format in Java
Filed under Java
Explore how to convert file size in bytes into a human-readable format in Java
Java Error “bad operand types for binary operator”
Filed under Java
Learn why we may encounter the Java compile-time error “bad operand types for binary operator” and how to resolve the problem
Find the Difference Between Two Sets
Filed under Java Collections
Learn how to find the asymmetric and symmetric differences between two Set objects through examples
Read User Input Until a Condition Is Met
Filed under Java
Learn how to handle multiple-line user input in Java
Java Operators
Filed under Java
Walk through all Java operators to understand their functionalities and how to use them
Pretty-Print XML in Java
Filed under XML
Learn two approaches to pretty-print an XML file in Java
Read a File Into a Map in Java
Filed under Java Collections
Learn two approaches to read content from a text file and save it in a Java Map object along with three strategies to handle duplicate keys
Java HashMap With Different Value Types
Filed under Java Collections
Learn two approaches on how to make a Java HashMap support different types’ value data
Invoke a Static Method Using Java Reflection API
Filed under Java
Learn how to invoke public and private static methods using the Java Reflection API
Java Classpath Syntax in Linux vs. Windows
Filed under Java
Learn how to set the Java classpath on different operating systems and what to watch out for.
Remove HTML Tags Using Java
Filed under Java
Learn how to remove all HTML tags and extract the text from an HTML document string
Count Spaces in a Java String
Filed under Java
Learn various ways to count how many spaces are in a string through examples
Squash the Last X Commits Using Git
Filed under Programming
Learn what Git squashing is, talk about when we need to squash commits, and take a closer look at how to squash commits
Running a Single Test or Method With Maven
Learn how to execute tests during a Maven build using the Maven surefire plugin
Disable the Maven Javadoc Plugin
Filed under Maven
Learn how to temporarily disable the Javadoc generation in Maven builds.
Is java.sql.Connection Thread-Safe?
Filed under Java Concurrency, Persistence
Learn if java.sql.Connection implementations are thread-safe
Start Two Threads at the Exact Same Time in Java
Filed under Java Concurrency
Learn two approaches to start two threads simultaneously: using CountDownLatch and CyclicBarrier
Concatenate Two Arrays in Java
Filed under Java
Learn how to concatenate two arrays in Java using the standard Java API and commonly used libraries
Java Deque vs. Stack
Filed under Java Collections
Compare the Java Stack class and the Deque interface and learn why we should use Deque over Stack for LIFO stacks
Java Warning “Unchecked Cast”
Filed under Java Collections
We’ll discuss what “unchecked cast” compiler warning means, why we’re warned, and how to solve the problem
Java Warning “unchecked conversion”
Filed under Java
Take a deeper look at the “unchecked conversion” compiler warning message
Jackson: java.util.LinkedHashMap cannot be cast to X
Learn why the “java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to X” exception occurs and how to solve the problem
Difference Between spring-boot:repackage and Maven package
Filed under Maven, Spring Boot
Learn the difference between mvn:package and spring-boot:repackage
Viewing Contents of a JAR File
Filed under Java
Learn ways to list a JAR file’s content from the command-line
Jdbc URL Format for Different Databases
Filed under Persistence
Take a closer look at the JDBC URL formats of several widely used databases: Oracle, MySQL, Microsoft SQL Server, and PostgreSQL
Get a Filename Without the Extension in Java
Filed under Java
Learn various ways to remove the extension from a filename
Extending Enums in Java
Filed under Java
Learn how to extend Enums in Java.
AbstractMethodError in Java
Filed under Java
Take a closer look at Java’s AbstractMethodError and understand what it is and when it may happen
Get Names of Classes Inside a JAR File
Filed under Java
Learn how to get names of classes inside a given JAR file and how to load classes from a JAR file at runtime.
Get the Running Port in Spring Boot
Filed under Spring Boot
Learn how to get the HTTP port programmatically in a Spring Boot application
The Difference Between a.getClass() and A.class in Java
Filed under Java
Learn the differences between calling the Object.getClass() method and using the .class syntax
Regular Expressions \s and \s+ in Java
Filed under Java
Learn about the difference between the two regular expressions through examples
Java Compiler Error: illegal start of expression
Filed under Java
See examples that illustrate the main causes of the “illegal start of expression” error and how to fix it
Baeldung on Linux
- All
- Files (54)
- Scripting (41)
- File Editing (20)
- Administration (16)
- Processes (10)
- File Searching (10)
- Filesystems (6)
- File Viewing (4)
- Search (3)
- File Permissions (3)
- Web (2)
- Security (1)
- File Compression (1)
How to Operate on Files Listed in a File
Learn to use various techniques to operate on files listed in a file.
What’s the Meaning of $! in Bash Scripting
Learn the meaning of the special shell variable $!.
Extract Text Between Two Specific Characters in the Command Line
Learn how to extract text between two specific characters using grep, sed, and awk through examples.
How to List Files Not Matching a Given String in the Filename
Filed under File Searching
Learn how to list files whose filenames don’t match a given pattern.
How to Check Whether Date Argument Is in the yyyy-mm-dd Format
Filed under Scripting
Explore different ways of checking whether a date argument is in the “yyyy-mm-dd” format.
How to Find Lines Exceeding a Certain Length in a File
Filed under File Searching
Learn three ways to find lines exceeding a specific length in a file.
Getting the Kernel Command-Line Parameters
Filed under Administration
Explore how to get the kernel command-line parameters in the current running Linux system
Print the Count of Lines Together With a Command’s Output
Filed under Scripting
Learn three ways to print a command’s output and the total number of lines in one shot.
Printing awk Output in the Same Line
Filed under Scripting
Learn three approaches for awk to print records in the same line with examples.
How to Filter strace’s Output Using grep
Filed under Administration, Processes, Scripting
Learn how to use the grep command to filter strace’s output.
Matching Multiple Strings Using Only One grep
Filed under Files
Learn how to search multiple strings using only one grep process
Returning Filenames Without Extension Using find
Filed under Files
Learn how to tell find to output only filenames without extensions.
How to Process a Bash Variable With sed
Filed under Scripting
Learn three approaches to using an external command to process shell variables
How to Sum Up the Size of Files Listed
Filed under Files
Learn how to sum up the size of listed files using the ls and find commands
Find Statistics on File Types Recursively in a Directory
Filed under Files
Learn two methods to recursively find statistics on file types in a directory
How to Use which on an Aliased Command
Filed under Administration, Scripting
Learn how to get an executable’s path when it’s in an alias
Command-Line Tools for Printing a Blank Line Between Lines of a Text File
Filed under File Viewing
Learn how to output a blank line after each line in the file using Linux command-line tools.
Implementing a Command Line Progress Bar
Filed under Scripting
Learn how to implement a customizable, reusable command line progress bar using shell script.
Setup a Ruler on a Specific Column in Vim
Filed under File Editing
Learn how to set column rulers in the Vim editor and customize them.
How to Make Output Overwrite the Same Line in a Terminal
Filed under Scripting
Explore how to overwrite an output line using the echo and printf commands.
Use grep to Show Only Filenames on Linux
Filed under Files
Learn how to list only the names of the files that match the given pattern.
Get Username by User ID in Linux
Filed under Administration
Learn how to find the user’s name by a given UID
How to grep the ps Output With Headers
Filed under Processes
Learn how to find desired processes and preserve the header line of ps’s output.
Find Processes by Keyword in Linux
Filed under Processes
Learn how to find processes’ information by a keyword.
How to Check Cron Logs in Linux
Filed under Administration
Learn how to check the cron jobs’ logs for two common cron implementations and two different logging systems.
List Only Non-Empty Files in Linux
Filed under Files
Learn how to use the find command to list non-empty files under a directory
Recall the Previous Command or Its Arguments in Bash
Filed under Scripting
Learn some tricks to reuse different parts from the last command in Bash
When to Avoid Using && in Shell Scripts
Filed under Scripting
Start from a script example and discuss a case we should avoid using && when writing shell scripts
Remove Duplicate Lines from a File Without Sorting
Filed under Files
Learn how to use awk to remove duplicate lines from an input file
Get the Current User in Linux
Filed under Administration
Learn how to identify the current user in Linux
Adding a Column of Values in a Tab Delimited File in Linux
Filed under File Editing
Learn how to add a new column to a given TSV file in the Linux command line
Get the Name of a Process from PID
Filed under Processes
Explore how to get the process name by a given PID
Concatenate String Variables in Bash
Filed under Scripting
Learn how to use Bash’s += operator and parameter expansion to concatenate variables
Difference Between Sourcing and Executing a Shell Script
Filed under Scripting
Learn the difference between sourcing a script and executing a script in Linux through examples
Quickly Clear the Contents of a File in Linux
Filed under File Editing
Learn how to clear only a file’s content from the Linux command line and keep the empty file
Bash Command to Check if Oracle or OpenJDK Is Installed
Filed under Administration
Learn how to check if the current Java environment is Oracle JDK or OpenJDK
Split a List by Comma in Bash
Filed under Scripting
Learn how to parse CSV format data in Bash through examples
Find Matching Text and Replace the Next Line
Filed under File Editing, File Searching
Learn how to search a pattern and apply some text substitution in the next line using sed and awk
Using grep After a Specified Line Number
Filed under File Viewing
Learn three approaches to search for a pattern in a file, starting after a given line number
How to Specify More Spaces as the Delimiter Using cut
Filed under Files
Learn two approaches to extracting fields from input when the delimiter is multiple spaces
List Files in a Zip Archive Without Decompressing
Filed under File Compression
Learn how to list the files in a Zip archive without decompressing it
Why Is \d Not Supported by grep’s Regex
Filed under File Searching
Learn why Regex \d isn’t supported by Linux commands such as grep and sed
Substitute Shell Variables in a Text File
Filed under Administration, Scripting
Learn how to substitute shell variables with their values in a text file in the Linux command line
Use grep to Find Content in Files and Move Matched Files
Filed under Files
Learn three approaches using grep to search files and move the found files to a directory in one shot
The /bin/true and /bin/false Commands in Linux
Filed under Scripting
Take a closer look at the /bin/true and /bin/false commands with some use cases
grep in a tar.gz Archive
Filed under File Searching
Learn how to do grep on a tar.gz archive to find which files contain an interesting pattern
How to Swap Two Files in the Linux Command Line
Filed under Files
Learn how to swap two files’ content using three mv commands
Round a Divided Number in Bash
Filed under Scripting
Learn how to perform various rounding methods in Bash
Set Environment Variables for a Bash Command
Filed under Scripting
Learn how to set environment variables only for one single command
Show Only the N-th Line After the Match
Filed under File Viewing
Learn how to only print the n-th line after the match using grep, sed, and awk
Return Value of Substitutions With sed and awk
Filed under Scripting
Learn how to return different values from sed and awk depending on the substitution result
xargs With Multiple Arguments
Filed under Scripting
Learn how to use the xargs command to handle multiple arguments
tar Files of Certain Types
Filed under Files
Learn how to use the find and tar commands to archive files of certain types
Use sudo Command in Non-Interactive Mode
Filed under Administration
Learn approaches to run a command as the superuser without asking for a password
Skip Hidden Files and Directories During Recursive Copy
Filed under Files
Learn how to copy directories recursively while excluding hidden files and directories
Linux – wget Timeout
Filed under Web
Take a closer look at wget’s timeout settings
Check if a Library Is 32-Bit or 64-Bit
Filed under Files
Our Linux distro may contain a mixture of 32 and 64 bit libraries. We can find out the architecture the library was built for by using a couple of commands. We explore how to do this for static and shared libraries.
List One Filename per Line in Linux
Filed under Files
Learn how to use the ls command to list one file per line
Including Additional Files in .bashrc
Filed under Administration
Learn how to include additional scripts in the .bashrc file through examples
Insert a Line With Spaces Using sed
Filed under File Editing, Files
Take a closer look at how to use the sed command’s feature for inserting a new line when the new line contains spaces
Get the Last Word From Each Line
Filed under Files
Learn two ways to get the last word from each line of a file
Get CPU Usage of One Single Process Periodically
Filed under Processes
Learn how to build simple shell scripts to log the CPU usage of a single process
The Last Modification Time of a Directory
Filed under Files
Learn how to get a directory’s last modification time and what changes to a directory will affect the modification time
Merge Two Files Line By Line in Linux
Filed under File Editing, Files
Learn how to column-wise combine two input files through examples
Split a File With the Header Line
Filed under File Editing, Files
Learn how to split an input file with the header line using the split and awk commands
Remove All Whitespace Characters From a Text File
Filed under File Editing, Files
Commands That Will Open a URL in the Default Browser
Filed under Web
Learn several ways to open a URL in the default browser from the Linux command line
Linux: Delete Files Listed in a File
Filed under Files
Learn how to delete files listed in another file using pure Bash, xargs, sed, and awk
Delete All Lines in a File Starting From a Specific Line
Filed under File Editing, Files
Learn how to delete lines from a given line number until the end of the file using head, sed, and awk
Read a Specific Line From a File in Linux
Filed under Files
Learn different approaches to read a specific line from a file
Get the Last Directory or Filename From a File Path
Filed under Files
Learn how to extract the last component from a given path string
Identify User in a Bash Script Called by sudo
Filed under Scripting
Learn two different ways to get the current login user in the shell script and a few common pitfalls
Extracting a Substring in Bash
Filed under Scripting
Learn various ways to extract substrings using the Linux command line
How to Copy a Directory to an Existing Directory in Linux
Filed under Files, Filesystems
Learn how to recursively copy a directory to an existing directory with or without overwriting
Redirect Output to Location With “Permission denied” Error
Filed under File Permissions
Learn how to overcome the “Permission denied” error when redirecting output to a file.
Remove the Last Character From Each Line in Linux
Filed under File Editing, Files
Learn how to remove the last character from all lines in a file through examples
How to Remove Symbolic Links
Filed under Administration, Filesystems
Learn how to remove a symbolic link using the rm and unlink commands
Preserve Linebreaks When Storing Command Output to a Variable
Filed under Scripting
See why linebreaks in a shell variable can disappear in echo’s output and learn the right way to use shell variables in commands
Find and Delete Files and Directories
Filed under File Searching, Files
Learn three different ways to delete files or directories found by the find command
Using grep on Files That Match Specific Criteria
Filed under File Searching, Files
Learn how to execute grep on a set of filtered files
Print Lines Between Two Patterns in Linux
Learn how to extract data lines between two patterns.
How to Create Soft Links to Directories
Filed under Filesystems
Learn how to create soft links to directories through examples
List All Groups in Linux
Filed under Administration
Learn two approaches to get all groups defined on the system
Copy Directory Structure Without Files
Filed under Filesystems
Learn three different ways to clone a directory structure without copying files under it through examples
Copy and Create Destination Directory if It Does Not Exist
Filed under Filesystems
Learn how to create the non-existing target directory automatically when we copy files
Find Files Not Owned by a Specific User in Linux
Filed under File Searching, Files
Learn how to search for files not owned by a particular user using the find command
Changing the Default Shell in Linux
Filed under Administration
Learn how to change a user’s default shell through examples
Linux Bash: Multiple Variable Assignment
Filed under Scripting
Take a closer look at how to do multiple variable assignment in Bash scripts
Showing a GUI Notification From a Shell Script in Linux
Filed under Scripting
Learn how to send a GUI notification from a shell script using notify-send and zentity
sed Substitution With Variables
Filed under File Editing, Files
Take a closer look at some common mistakes made using sed substitution with shell variables
Evaluate XPath in the Linux Command Line
Filed under File Searching, Files
Learn how to evaluate XPath expressions using xmllint, XMLStarlet, and xidel
Using sed With a Literal String Instead of an Input File
Filed under Scripting
Have a look at how to use the sed command to process a literal string or shell variable.
Remove the First Line of a Text File in Linux
Filed under File Editing, Files
Learn how to remove the first line from using sed, awk, and tail
Using Vim Registers
Filed under File Editing, Files
Learn about each type of Vim register through examples
How to Remove the Lines Which Appear in File B From Another File A in Linux
Filed under File Editing, Files
Learn several approaches to remove the lines that appear in file B from another file A
Remove the Last N Lines of a File in Linux
Filed under File Editing, Files
Learn different ways to remove the last n lines from an input file and the performance of those approaches
Splitting a File at Given Line Numbers
Filed under File Editing, Files, Scripting
Learn how to split a file at given line numbers using head, tail, sed, and awk
How to Delete Multiple Files at Once in Bash
Filed under Scripting
Learn how to delete multiple files in one shot from the Linux command line
Run a Function in a Script from the Command Line
Filed under Scripting
Learn how to call shell script functions from outside the shell script file
Count Duplicated Lines in a Text File
Filed under Files
Learn a few ways to count repeated lines in a text file
Implement a Counter in Bash Script
Filed under Scripting
Learn how to implement a counter in a Bash script and some common pitfalls
Save Modifications In-Place with awk
Filed under Scripting
Learn how to do in-place editing with the awk command through examples
Recursive Search and Replace in Text Files
Filed under File Editing, Files, Search
Learn how to search and replace in text files recursively through examples
Easy Ways to Determine Virtualization Technology
Filed under Administration
Learn how to determine virtualization technology using Linux commands
Send stdout to Multiple Commands
Filed under Scripting
Learn how to send the output of a command to multiple commands using three different solutions through examples
How to Print the Longest Line(s) In a File
Filed under Files
Learn different ways to find the longest lines from an input file and benchmark their performance
How to Pretty-Print XML From the Command Line
Filed under File Viewing, Files
Learn several ways to pretty-print an XML file using Linux commands
Reading Output of a Command Into an Array in Bash
Filed under Scripting
Learn a few ways to save multi-line output into a Bash array
How to Show All Shared Libraries Used by Executables in Linux?
Filed under Processes
Learn several ways to list all shared libraries used by a program
How to Call an External Program Using awk
Filed under Scripting
Learn how to call an external program using awk
Linux Job Control: &, disown, and nohup
Filed under Processes
Learn about three common approaches to start a process and let it run in the background as a job
How to Randomize Lines in a File in Linux
Filed under Files
Compare different ways to shuffle lines in text and discuss their pros and cons
Remove Blank Lines From a File
Filed under File Editing, Files
Explore some common scenarios for removing blank lines from a file through practical examples
How to Join Multiple Lines Into One
Filed under Scripting
Learn several ways to merge multiple lines of input into a single line with customized delimiters
Process Multiple Input Files Using Awk
Filed under Files
Learn how to process multiple input files using the awk command using simple examples
Linux last Command
Filed under Administration
Learn how to get login related information using the last and lastb commands
Shut Down and Reboot Linux Systems From the Terminal
Filed under Administration
Learn some useful commands to reboot and shut down a Linux system from the command line
Is There a Way to ‘uniq’ by Column?
Filed under Scripting
Learn how to do the “uniq” operation on a column instead of the entire line
date Command in Linux
Filed under Scripting
We’ll take a closer look at the date utility and learn its common usages
The head and tail commands in LINUX
Filed under File Editing, Files
Learn about the typical usages of the head and tail command through examples.
Linux watch Command
Filed under Scripting
Learn how to use the watch command to execute a command periodically and check the output of each execution
The echo Command in Linux
Filed under Scripting
Learn the echo command and its options through examples
Linux sort Command
Filed under Files
Learn the sort command through various examples
Advanced File Permissions in Linux
Filed under File Permissions, Files, Security
Learn about special file permission flags in Linux
Linux tr Command
Filed under Files
Learn how to use the tr command through various examples
Introduction to File Locking in Linux
Filed under File Permissions, Files
Learn about two types of file locks in Linux some related commands through examples
Introduction to File MIME Types
Filed under Files
Learn about MIME types and how to get the MIME type of a file using Linux command-line utilities
Renaming Linux Files in Batches
Filed under Files
Depending on the Linux distro and use case, there are a few available tools that can rename a batch of files. We explore some common use cases.
Finding the PID of the Process Using a Specific Port
Filed under Processes
Learn different approaches to finding the process listening on a particular port in Linux
How to Mount and Unmount Filesystems in Linux
Filed under Filesystems
Learn how to use the Linux mount command to attach various filesystems and detach them with umount
Guide to Useful File Manipulation Commands
Filed under File Editing, Files
Learn about some useful file manipulation commands in Linux.
Common Linux Text Search
Filed under File Searching, Files, Search
Learn how to perform some common text searching in Linux using the grep command-line utility
Baeldung on Kotlin
- All
- Kotlin Collections (8)
- Kotlin Classes and Objects (7)
- Kotlin Basics (7)
- Kotlin Strings (5)
- Kotlin Numbers (2)
- Kotlin (2)
- Kotlin Functions (1)
Get a Not Null Value From a Map in Kotlin
Filed under Kotlin Collections
Take a closer look at Kotlin’s get operator and explore different approaches to get a not-null value from a Map.
Reversing a Map in Kotlin
Filed under Kotlin Collections
Learn a few ways to reverse a map through examples using Kotlin.
Conversion Between Camel Case and Snake Case in Kotlin
Filed under Kotlin Strings
Learn how to convert between camel case and snake case strings through examples.
Flatten List of Lists in Kotlin
Filed under Kotlin Collections
Learn three approaches to flattening a list of lists with examples.
Mark Unused Parameters in Kotlin
Filed under Kotlin Basics
Learn how to mark unused parameters in Kotlin’s regular functions and lambda expressions.
What Does “with” Mean in Kotlin?
Filed under Kotlin Basics, Kotlin Functions
Learn how to use the with() scope function in Kotlin
Get the Type of a Variable in Kotlin
Filed under Kotlin Classes and Objects
Learn how to get the type name of a variable in Kotlin
Catch Multiple Exceptions in Kotlin
Filed under Kotlin Basics
Explore how to implement the “multi-catch” feature in Kotlin
Convert String Into Enum in Kotlin
Filed under Kotlin Strings
Learn how to convert a string into an enum constant in Kotlin.
How to Turn String Templates Into Literal Strings
Filed under Kotlin Strings
Learn two ways to turn Kotlin string templates into literal strings.
How to Create “static” methods for Enum in Kotlin
Filed under Kotlin Classes and Objects
Learn how to create a “static” method in Kotlin’s enum class and how to call it from Java
Finding Enum by the Value in Kotlin
Filed under Kotlin Classes and Objects
Learn how to find an enum instance by a given value.
Data Class’s equals() Method
Filed under Kotlin Classes and Objects
Learn about Kotlin data class’s equals() method and common pitfalls.
Trailing Comma Support in Kotlin
Filed under Kotlin Basics
Learn about trailing comma support and its benefits.
Extending a Class and Implementing Interfaces at the Same Time in Kotlin
Filed under Kotlin Classes and Objects
Learn how to extend a class and implement interfaces simultaneously in Kotlin
Convert Boolean to Int in Kotlin
Filed under Kotlin Numbers
Learn two approaches to convert a Boolean object to an Int through examples
Multiple Variables “let” in Kotlin
Filed under Kotlin
Learn how to apply let-like operations on multiple variables
Pad a Number in Kotlin
Filed under Kotlin Numbers, Kotlin Strings
Learn how to pad numbers in Kotlin using two approaches: String.format() and padStart()/padEnd()
Add an Element to a List in Kotlin
Filed under Kotlin Collections
Learn how to add an element to Kotlin’s three common list types
Type Checks and Casts in Kotlin
Filed under Kotlin Basics
Learn how to check the type of a given object in Kotlin and two kinds of cast approaches
Fixing the Kotlin Error “Smart cast to ‘Type’ is impossible”
Filed under Kotlin
Look into the compilation error “Smart cast to type is impossible” caused by Kotlin’s smart-casting a nullable type to the corresponding not-nullable type
Use of Boolean? in Kotlin if Statement
Filed under Kotlin Basics
Learn how to check nullable Boolean (Boolean?) values in Kotlin if statements
Check if an Array Contains a Given Value in Kotlin
Filed under Kotlin Collections
Learn how to check whether an Array contains a given element in Kotlin
Comparing Two Lists in Kotlin
Filed under Kotlin Collections
Learn how to compare two List objects with or without checking the elements order
Number Formatting in Kotlin
Filed under Kotlin Strings
Learn three ways to format decimal numbers in Kotlin
Anonymous Objects in Kotlin
Filed under Kotlin Classes and Objects
Learn how to instantiate an abstract class or interface using object expressions in Kotlin
Instantiate a Kotlin Data Class Using an Empty Constructor
Filed under Kotlin Classes and Objects
Explore two approaches to instantiate a Kotlin data class using an empty constructor
Define Multiple Variables at Once in Kotlin
Filed under Kotlin Basics
Learn the Kotlin way of declaring and assigning multiple variables in one line
Convert a List Into an Array in Kotlin
Filed under Kotlin Collections
Learn how to convert a List into an Array in Kotlin
Convert Between List and Set in Kotlin
Filed under Kotlin Collections
Learn how to convert between Set and List in Kotlin
Often we need to remove whitespace from files in Linux. This needs special processing if we want to include Unicode or line breaks. We look at how to solve this with a few common command line tools.