Skip to content

Tag: file

Reading numbers from file and normalizing

Hello Everyone, I want to load the data I have in a file, which looks like: Now, I want to load this from the file and compute the normalization. I do: But, I am getting the error: Although, I do the process directly into python 2.7 console in linux like, This works fine. I don’t know what I am doing

Can mmap and O_DIRECT be used together?

As I understand it, when you mmap a file you are basically mapping the pages from the page cache for that file directly into your process, and when you use O_DIRECT you are bypassing the page cache. Does it ever make sense to use the two together? If my understanding is right how would it even work? mmap seem…

C Just Delete Some Part Of File

I have two files. I want to copy source file to destionation file. If they are different, then I just want to copy different line not all file. In the below case, two line are same, but destination has extra line. How can I just delete last line of destination file? For example: Answer On POSIX systems, if yo…

Signal and output in c

Some time ago I found this exercise in C: without changing the main function, so that receiving a SIGUSR1 signal output is directed and added to a file in append mode as the first parameter. At the reception of another SIGUSR1 the output is directed to the console, and so on. How do such an exercise? Answer I…

Comparing tow large files line by line

I was wondering if there is any efficient way to compare 2 large files line by line. File 1 File 2 I am just taking the first character of each file and comparing against them. Currently i am using a very naive method of iterating through them in a double for loop. Like Reading both files into memory is not

Disable Cache/Buffer on Specific File (Linux)

I am currently working in a Yocto Linux build and am trying to interface with a hardware block on an FPGA. This block is imitating an SD card with a FAT16 file system on it; containing a single file (cam.raw). This file represents the shared memory space between the FPGA and the linux system. As such, I want …

Modification of file names

I have a list of more than 1000 files on the following format. I am on Linux and want to change them as follows Using rename and awk I managed to get The remaining task is now to remove the last field that holds the year. Answer A solution that uses sed to generate the new names and the rename