Skip to content
Advertisement

Tag: file

conditionally merge files by appending in bash

I have two files and would like to merge them – by appending to the last line. file1.txt content file2.txt content Desired outcome – file3.txt How do I go about this, please? Note, zero is in place for null in the Stack line. Answer Using awk: When file2.txt is read, store field2 in array a using field1 as index. When

Delphi 10.3 Linux exclusive file access

How can I lock a file in Linux with a filestream? Creating a filestream like in the example below works perfectly in Windows, the file is locked and cannot be deleted or written to in other sessions until the stream is freed. Under Linux I can delete the file or write to it in an other session without any problems.

Searching a text file backwards from the end

I’m trying to find the string containing the substring in a text file by starting at the end. The file has tens of millions of lines. (The requirement is to read from End of the File. I cannot use sed/awk/grep etc) The below program does the job but it takes a long time. How can I make it run faster?

How to split file based on first character in Linux shell

I do have a fixedwidth flatfile with the header and detail data. Both of them can be recognized by the first character: 1 for header and 2 for detail. I want to genrate 2 different files from my fixedwidth file , each file having it’s own record set, but without type record written. File Header.txt having only type 1 records.

Search string in file via bash but only work match

Find the only string name based on the sub string name in a file. Command used: What works: File content: Output (desired output): What does not work: File content: Output: Need output SomeApi-CURRENT.war Answer It appears, you are interested in the docBase attribute of your xml elements. Specifically those where the value string contains “current” as a substring. But this

c++ close a open() file read with mmap

I am working with mmap() to fastly read big files, basing my script on this question answer (Fast textfile reading in c++). I am using the second version from sehe answer : and it works just great. But if I implement it over a loop of several files (I just change the main() function name to: and then get the

Advertisement