Skip to content
Advertisement

Tag: file

What is a better way to read each line in a file in linux?

Hi all, I want to read each line in a file and then make a whole url to do some thing. The above scripts worked, but what is a better way to read file line by line? Thanks. Answer This is a nice example of the useless use of cat, simply use IO redirection: The use of -r in read

C: strtok and newlines in Windows vs Linux

I’m working on a C school assignment that is intended to be done on Windows, however, I’m programming it on OS X. While the other students working on Windows don’t have problems reading a file, I do. The code provided by the tutors splits the contents of a file on n using this code: However, the file adfgx.txt (which is

I read more than I write in file

I have a file, partitioned in fixed sized blocks. I am copying a test_file.txt into the 3rd block of the file. I read and copied 18 bytes. Then I am trying to copy from the file that very same .txt file I just imported to a newly created .txt, but I am writing 256 bytes to the new file. Moreover,

How do I do a one way diff in Linux?

How do I do a one way diff in Linux? Normal behavior of diff: Normally, diff will tell you all the differences between a two files. For example, it will tell you anything that is in file A that is not in file B, and will also tell you everything that is in file B, but not in file A.

Invalid conversion from ‘FILE* {aka _IO_FILE*}’ to ‘int’

When trying to compile this little example… …I get a compiler error regarding the call to lseek(). The output is: For the record: I have also tried using both lseek(*foo, 5, SEEK_CUR); and lseek(&foo, 5, SEEK_CUR);, but that only makes things worse. (I really didn’t expect that to solve anything either.) Referring to the man-page for lseek(3): Synopsis off_t lseek(int

Alternative to writing many files. MongoDB?

I have a Perl script that produces ~10000 files in the 1kB – 10kB size area, which is not optimal for performance, so I though about using MongoDB instead of writing the many files. I need to run the script on my laptops Linux and OSX. Question Would MongoDB be overkill? Or are there something more suited for this sort

Unable to configure folder permissions in Ubuntu

I found many related questions and tried to solve the issue but I was not successful. Actually I created an user named “amit” and assigned the group “www-data”. I gave permission to the folder using this method Change folder and file permission recursively: To change all the directories to 755 (-rwxr-xr-x): To change all the files to 644 (-rw-r–r–): But

Advertisement