Skip to content

Tag: file

Compare columns from two files and print not match

I want to compare the first 4 columns of file1 and file2. I want to print all lines from file1 + the lines from file2 that are not in file1. I don’t understand how to print things that don’t match. Answer You can do it with an awk script like this: script.awk And run it like this: awk -f script.aw…

Why can’t bash recognize the existence of a socket file

On a Linux box I want to check if a specific socket file exists. I know the socket files exists, but my checks in bash don’t show that to me: Why oh why can’t bash see that the file exists? Answer http://www.tldp.org/LDP/abs/html/fto.html Use -S to test if its a socket. -f is for regular files. Se…

Organize file by Linux

I want to thank the great help and support. Well, I have the following file: and I need that file be this way: Please, someone can help me? Thank you very much Answer awk to the rescue!

linux get specific fields from several files

I have several files starting with the string “file” then a number (file1, file2, etc). The content of these files is similar and looks like this For each file, I want only keep the index of the element and the 2 numeric fields just after coordinates (in the same file or in another file): file1: W…

linux kernel: is vfs_write thread safe?

In my program, I need to write file in kernel space due to some special reason although I know it’s not recommended. I’m using vfs_write to write files in kernel space and it works fine. In one case, there are two threads need to write to the same file. From the internet, it seems that user-space …

link count and ls command

I’m learning file link count. Only when link count reaches 0 can file’s contents be deleted. In my test the process opens a file in directory “/home/hel/myfile” and sleep 10(s). At the same time I delete it using “rm /home/hel/myfile”. Then I use command “ls” and disp…