Skip to content
Advertisement

Tag: cat

Simple way to call ‘cat’ from c++?

I am writing some C++ code and I need to pre-allocate an array based on the contents of a file. I can definitely read the the file and parse the strings a certain way, but it’s must easier to find the proper number from the following Linux one-liner: What is the best way to use this single one liner on

concatenate ordered files using cat on Linux

I have files from 1 to n, which look like the following: Each file contains only one line. Now I want to concatenate them in the order from 1 to n. I tried cat sim.o500.* > out.dat. Sadly this does not work if e.g. n is larger than 9, because this concatenates then sim.o500.1 followed by sim.o500.10and not sim.o500.1 followed

Bash: add string to the end of the file without line break

How can I add string to the end of the file without line break? for example if i’m using >> it will add to the end of the file with line break: I would like to add yourText2 right after yourText1 Answer If your sed implementation supports the -i option, you could use: With the second solution you’ll have a

Concatenating Files And Insert New Line In Between Files

I have multiple files which I want to concat with cat. Let’s say I want to concat so that the final file looks like: Instead of this with usual cat File*.txt > finalfile.txt What’s the right way to do it? Answer You can do: Make sure the file finalfile.txt does not exist before you run the above command. If you

Print contents of a PDF to the command line

I’m looking for a command-line program that will print out the text of a PDF file, just like cat for a text file. I’ve found pdftotxt, and that would be workable, but I’d prefer something that replicates the cat functionality because I want to pipe to grep. Thanks! Answer On the man pages for pdftotext, I found this: pdftotext [options]

Advertisement