If you ever need to move a file in Scala, I can confirm that this approach works:
One of my favorite ways to use the Unix
awk command is to print columns of information from text files, including printing columns in a different order than they are in in the text file. Here are some examples of how
awk works in this use case.
I updated my Scala Flat File Database project so it now handles newline (
\n) characters. The solution isn’t perfect, but it’s a start, and makes the approach much more usable. (I didn’t need this functionality until today, so I didn’t know it was a problem.) I also updated it to work with Scala 2.12.
As a brief note about the Linux/Unix
sed command, today I learned how to append multiple lines of text to an HTML (or XML) file on macOS. The short answer is that I created a
sed commands file named changes.sed with these contents:
Here’s some source code for a Scala method that reads a text file that may have comments into a
Unix/Linux shell script FAQ: How do I write a Unix or Linux shell script where I "do something" for every line in a text file?
Solution: An easy way to process every line in a text file is to use a Unix/Linux while loop in combination with the Linux cat command, like this:
I just noticed that some of the MySQL files on this website had grown very large, so I wanted to be able to list all of the files in the MySQL data directory and sort them by filesize, with the largest files shown at the end of the listing. This
ls command did the trick, resulting in the output shown in the image:
-S option is the key, telling the
ls command to sort the file listing by size. The
-h option tells
ls to make the output human readable, and
-r tells it to reverse the output, so in this case the largest files are shown at the end of the output.
I made a mistake in configuring
logrotate on a new Linux system, and almost ran into a problem because of that. Fortunately I saw the problem before it became a BIG problem, but as a result, I decided to add a script to my Linux system to check for large files, typically log files that have grown out of control for one reason or another.
Here then is a simple Linux shell script I named LargeFileCheck.sh, which searches the filesystem for files that are larger than 1GB in size: