Gmt convert how to supress > symbols when pasting two txt files

In GMT 6.4.0, when using

gmt convert fileA.txt fileB.txt > fileC.txt

to combine some rows of records from fileA with rows of records from fileB, there are “>” symbols (i.e., great than symbols) occupying some rows in the fileC. I wonder how I can suppress the write out of these “>” ?

I think we need more context. > characters are used to separate data segments. Suppressing them is not the solution.

I see. The context is that I am looking for a quick GMT solution to prepare a ASCII text file that will be fed into a mesh generator; therefore the need of removing those “>” characters.

That text file is a combination of two output files from other gmt programs.

Just to be clear, do you want to remove the segment marker within a multisegment file? Are the “>” in the original files (fileA.txt and fileB.txt)? Or were added by GMT when you use gmt convert?

In this case, you could use cat instead of gmt convert

cat fileA.txt fileB.txt > fileC.txt

There have been occasions when I’ve needed to do this type of thing, from time to time.

Since your files are text files, you can use an awk command.

After creating fileC.txt, and presuming that the “>” appear only in lines you want removed, issue this command:

awk ' $0 !~ />/ ' fileC.txt > fileD.txt

The !~ (no match) operation examines each line, and if “>” is found anywhere in the whole line, skip it, otherwise write-out all remaining lines. Awk is one of the foundational tools for scripting, and it operates very quickly. [Many pardons for those in the group who despise awk! :slightly_smiling_face:]

For a GMT solution, try

gmt convert *.txt -Th > noheaders.txt

Thanks for all the solutions ! Seems all work well for my case !

Especially the awk solution (Thanks John). Sometimes I forget this powerful Linux program as well :slight_smile: