Java convert a list to a csv string

Here’s an easy way to convert a list of Strings to a String containing csv values <pre  class=”brush:java”> StringUtils.join(list, ‘,’) </pre> To reverse conversion can be done by – csv to list <pre  class=”brush:java”> Arrays.asList(StringUtils.split(rs.getString(“a,b”), “,”)) </pre>  

Systemd and Systemctl – services, units and run levels

systemd has replaced the univ SysV (System V) and BSD init systems  in majority of the linux distributions. Centos 7 now has systemd and has changed the way services are handled. This is not a comprehensive tutorial but a simple introduction on how services are added, started, enabled, listed and removed using systemctl. Before we … Read more

cat all files recursively in a directory

find . -name ‘*.txt’ -exec cat {} \; This command finds all files that have an extension of .txt in the current directory and its sub directories and executes a cat command on them

Total size of a directory in unix

Use the du command to get the size of a directory du -h prints the size of current directory and each directory under it in a human readable form. To get the size of the current directory only use this command du -sh to get the size of a particular directory du -sh

read a file in reverse

At times it is required to read a file in reverse. i.e. starting from the last time and reading up. The best way to do this is to use the ‘tac’ command tac filename

Merge multiple text files into another file

One way to merge multiple text files into a new text file is to use the cat command. cat file1.csv file2.csv > file3.csv This command merges file1.csv and file2.csv into a new file called file3.csv we can also append to an existing file instead of creating a new one cat file1.csv file2.csv >> file3.csv This … Read more