Find Unix File by Date or Time

I needed to find all files in my Unix directory that were created within a certain timeframe.

Here’s how to find all that were created on a set date:

find -type f -name “*” -newermt “2019-07-01” ! -newermt “2019-07-02” -ls

Here’s how to find within a time frame:

find -type f -name “*” -newermt “2019-07-01 00:00:00” ! -newermt “2019-07-01 08:00:00” -ls

It finds all files “newer than” the first value, but then excludes any files that are “newer than” the second value.

batch remove periods from files

I had a user that had a folder of files that had a lot of .’s in the names.  As an example:
I.like.kayaking.txt
This.is.a.sample.file.txt

They needed all of the .’s replaced with a space.  Here is the contents of the batch file that I created to fix the issue:


@echo off
 setlocal enableextensions disabledelayedexpansion

for %%a in (*) do (
 set "filename=%%~na"
 setlocal enabledelayedexpansion
 for %%f in ("!filename:.= !") do (
 endlocal
 ren "%%~fa" "%%~f%%~xa"
 )
 )

All the user has to do is copy the .bat file into the directory that has the problem files and then run the .bat file.

This is a slightly modified version of the script found at: https://stackoverflow.com/questions/28558996/batch-file-for-replacing-dots-with-spaces-in-file-names

Siding updates

I haven’t posted about the siding project for awhile.

All of the old siding is off and new sheathing is in place.

I did discover that the ceiling above our dining room had no insulation on it.

So I learned how to use an insulation blower (not hard) to blow insulation 16+ feet in (challenging) I attached the blower nozzle to the end of a pool pole and then used a long 1×6 to move the insulation into place. It was a bit messy as I got closer to the opening, but not too bad.

With the sheathing up, I was able to get the house wrap on. There is much debate online as to of house wrap should go above or below polystyrene insulation. I chose below as it would be easier to secure around windows.

I worked from the bottom up, over lapping each layer by a foot.

I am now in the process of getting the polystyrene up.

So much of it is now up that I had to remove the scaffolding. I’m hoping that I will be able to get all the siding up without it. I do still have my hoist in place to help with the heavier lifting up high.

Shell script to concatenate multiple csv files

I had a unix directory with multiple CSV files, all with the same prefix.  I needed them to be concatenated together to make one large file using a shell script.

I used the below code, copied multiple times (one for each file prefix)

Sample files:
file20170804.csv
file20170803.csv
file20170802.csv


new_file=”/dir/file.csv”
if [ -f $new_file ] ; then
rm $new_file
fi

for file in /dir/file?*.csv
do
tail -n +2 “$file” >> $new_file
done


Here is the code with comments:

1 new_file=”/dir/file.csv”
2 if [ -f $new_file ] ; then
3 rm $new_file
4 fi

5 for file in /dir/file?*.csv
6 do
7 tail -n +2 “$file” >> $new_file
8 done

1 – Name of the file you are creating
2 – 4 Check if the file already exists.  If so, then remove it
5 Loop through the smaller files.  Note that I have a ? to make sure that it is not trying to add the big file back to itself.
6-8 Concatenate the file to the $new_file, but ONLY lines 2-end of file.  This omits the header record of the .csv file.

Tractor update

While at the camp, I did get to spend a bit of time working on Little Red.  Not as much as I would have liked, but still made a bit of progress.

I spent some time taking the hood off.  I figured it would be necessary so that I could more easily get to everything.

Since the engine itself is still seized up, I figured it would be worthwhile to take the head off.  I was in for a surprise when I took some of the bolts off.  A strange colored liquid started coming out.

I did get all of them out.  Here is what it looks like:

I was expecting some liquid as I had poured a bunch of Kroil down the spark plugs, but Kroil is not green.

No idea what this stuff is.  One of my friends suggested that it might be anti-freeze?

I’m hoping that I will have more time to work on her during my next trip.  I had to leave with her all covered back up.  Thankfully, I did gain an additional gear-head friend that said he’d help 🙂

Trip to Camp

We spent a couple weeks up at the camp during the beginning of July.  Time was spent working on the trails…

 

Building a tree house for the kids…

With their help of course…

Enjoying nature…

(Including a trip to Lake Superior!)

And enjoying food…

 

 

Siding. Weekend 1

This weekend was the start of our big siding project. About a quarter of the existing siding panels are rotten. There is also no house wrap underneath. This means all of the siding needs to be pulled off and replaced.

I’m hoping that some of the panels can be salvaged enough to use on a playhouse or a deer blind.

My goal is to do one side of the house every year. I think that is the best use of resources, both in cost and in labor.

We decided to start on the west side since that feels the most drafty.

Step one was to get the scaffolding up…but the was no way I was lifting 32′ doubled up 2x4s by myself.  Electric hoist to the rescue!

Once the verticals were in place, I installed the pump jacks.

Now, I’ve never used a pump jack system before, so this was all new. I tried going up and down short distances to get myself comfortable. As you can see, there is a bit of height involved. I’m not afraid of heights, but I do need to feel comfortable with whatever is holding me.

I’ve decided that I’m comfortable going up, but only so so going down. I was going that I might be able to use the pump jack as an elevator of sorts to get larger pieces up and down. Nope. Not happening. Everything will be lifted/lowered with the electric hoist. I’ll use the extension ladder to get myself up and down.

I did make some progress getting the uppermost siding pieces off. In the process, I had access to inspect our attic.

Thankfully, the only bad joist connection is the one you see above. I did get it reinforced.

Here is the electric hoist setup. No. I am not standing on the work bench. I just stretched my arm out. Yes, the extra ladder is tied off. The pump jack is as high as I can get it, but I needed an extra foot to reach the peak. The ladder also allowed me access to the attic. It is a tight squeeze between the hoist support and the ladder, but I managed to fit.

I did have a visitor later in the evening. Apparently one of our cats figure out how to climb the extension ladder…

My wife was able to rescue the cat through the upstairs window.

Drainage ditch

We’ve always had a garden in our wall by our pool, but dirt keeps washing out of it. Two obvious reasons as to why…1.) Lack of drainage and 2.) A downspout drains directly to the garden.

Thankfully, I knew exactly where the drain was at that I put in last year. After some careful digging, I found it and was able to add a Y. I really lucked out that the power conduit that is next to the existing drain was on the far side…exactly where I needed it to be.

I used 4″ perforated drainage. Except Lowe’s only had one in stock, so I had to create one by drilling holes into it. The full length is then covered with a sock to keep crud out. 20′ of perforated plus a 10′ connector to the main drain = lots of dirt to move.

Here is the finished product.

 Flowers have been purchased. We just need some time and good weather to plant them.

Kansas Cub Fest 2017

I went to my first Cub Fest earlier today, not really knowing what to expect. It was a very relaxing event, with lots of good stories, good food, and even some tinkering going on.

I had the little kids wth me, which had me worried. What would they get into? Would I be able to participate without worrying about them? What would the other people think of me bringing two preschoolers to an adult event?

Well, I should not have worried. Phil and Katy did great, mostly staying out of trouble. I’m pretty sure most of the guys are grandfathers and it showed because they did not seem to mind the little ones there.

Phil even got to drive one of the tractors! (Katy was offered a ride, but she was too shy)

Phil on a Lo Boy tractor

He’s doing a pretty good job steering

Here is the crew enjoying a nice lunch…

Thank you again for the great time! Hopefully I will have a running cub by the next time we meet.

By the way, for anything and everything you’d like to know about this type of tractor, check out http://www.farmallcub.com

Thanks everyone!

Toy shelf

I built a pretty nice toy shelf over the weekend, plus a couple of hours today. Total time was right around 12 hours. This was the first project where I used a pneumatic nailer. I would say that pneumatic shaved at least a few hours off of the project time!

The shelf itself is 5 feet tall, which is what was needed to fit the tall toys. It is pretty sturdy just as is, but no chances were taken (especially with kids), so it is also screwed into two studs.

I did learn a few things with this project…

  1. Different length nails require different pressures. 1 inch nails were about 75 psi. 2 inch were about 100 psi. Both needed additional tweaking at the gun, which was very easy. The trick is to start at a lower pressure until you find what works. You can always use a punch and hammer to get the nail in further.
  2. Shelf pegs only work for shorter shelves. I ended up wasting time drilling holes for them just to find they would not be strong enough. I ended up using 1×2 supports instead.
  3. Side snips come in handy for the occasional nail that doesn’t quite hit its mark.
  4. Always double check you have the correct side (top, bottom, left, and right) before routing an edge. We ended up buying some quarter round for trim instead of just having a router made edge. Oh well. The trim does look pretty good and I got more experience with the nailer.

The nailer I used was a Hitachi NT65M2S 2.5 inch finish nailer. I have it hooked up to a 8 gallon Kobalt compressor, which cycled just a few times through the entire project.  

The main goal of this project was to find a better home for some of the kid’s toys. I’d say missing accomplished!