June 24, 2020

StitchingStitching

Cat For Stitching Files Together

I have been looking at a utility called Assembler for a while now. I need to merge text files together and have been considering buying Assembler to perform this task. It costs $9.99 and I have been debating whether it is worth that. I need that function occasionally and is it worth $9.99 to me?

Cat

A web-search lead me to Combine several text files into a single file in Unix. This is what they recommend.

You can join a bunch of files with the command:

cat file1 file2 file3 > newfile

Replace file1, file2, and file3 with the names of the files you wish to combine, in the order you want them to appear in the combined document. Replace newfile with a name for your newly combined single file.

If you want to add one or more files to an existing document, use the command:

cat file1 file2 file3 >> destfile

This command will add file1, file2, and file3 (in that order) to the end of destfile.

Note: If you use > instead of >>, you will overwrite destfile.

This looked easy enough to do and it was built into the OS.

Note: UNIX commands don’t like spaces in file names. Escape the spaces with \. For instance, the file world domination.md will be world\ domination.md.

Open in Terminal

I came across a useful utility called, Open in Terminal.

Open in TerminalOpen in Terminal

When I have a directory selected in a Finder window, I can press a keyboard command, ⇧⌘[, in my case, and my Terminal opens with the selected folder as the working directory.

I can then type cat and drag in to the terminal prompt the files I want combined, assign a filename to the combined file and press enter. It is quick and painless.

Running an OS with a UNIX underpinning gives the user a lot of power. It will be lucrative to discover what else it has to offer.

BBEdit

BBEdit solves this problem too.

From the BBEdit manual:

Inserting File Contents

The File Contents command inserts the contents of one or more files into the document you are editing. When you use this command, BBEdit displays an Open sheet in which you can choose the files to insert. To select more than one file hold down the Shift key or Control key as you click the files. BBEdit then inserts the contents of the selected files at the insertion point or replaces the selected text. If you select more than one file, the files will be inserted in alphabetical order, according to file name.

The Open sheet also presents an option named Include Separators, and if you enable this option, BBEdit will include a separator which consists of a dashed line and the file’s name between each inserted file’s contents.

You can also drag a file’s icon from the Finder into a BBEdit editing window to insert the contents of that file.

In BBEdit you can Choose Edit>Insert>File Contents… and from the dialog box choose the files you want added and you are ready to go.

It is a simple and easy way to achieve the act of joining a collection of files into one file.

Conclusion

I didn’t spend the money on Assembler. Managed to learn a valuable UNIX command and discovered a feature in BBEdit which I did not know about.

Note: Thanks to Photo by Alex Andrews from Pexels

macosxguru at the gmail thingie.


cat text macOS terminal


Previous post
Paletro Brings the Command Palette Everywhere Product: Paletro — Command Palette in any applications Price: $6.99 The first time I was exposed to the Command Palette was in Sublime Text. All the
Next post
WordWeb Pro and Others Product: WordWeb Pro Dictionary and Thesaurus for Mac OS Price: $4.99 Product: Chambers Thesaurus Price: $6.99 Product: Oxford Dictionary of English