Skip to content
Advertisement

Tag: unix

grep without showing path/file:line

How do you grep and only return the matching line? i.e. The path/filename is omitted from the results. In this case I want to look in all .bar files in the current directory, searching for the term FOO Answer No need to find. If you are just looking for a pattern within a specific directory, this should suffice: Where -h

How do I replace single quotes with another character in sed?

I have a flat file where I have multiple occurrences of strings that contains single quote, e.g. hari’s and leader’s. I want to replace all occurrences of the single quote with space, i.e. all occurences of hari’s to hari s all occurences of leader’s to leader s I tried and but they are not giving me the expected result. Answer

Create a hard link from a file handle on Unix?

If I’ve got a handle to an open file, is it possible to create a hard link to that file after all references to it have been removed from the filesystem? For example, something like this: Specifically, I’d like to do this so that I can safely write to large data files, then move them into place atomically without having

Clearing output of a terminal program in Linux C

I want to clear the output of a C program produced with printf statements. I want to clear only one line, for example: [source] [terminal] [I hope] I will “DDDDDDDDDDDDDD” line in write other string. I just want the above A, B, C sentences to left. Only clear D sentences to change the other sentences, unconditionally output D sentences. How

How does cmd > /dev/null 2>&1 work?

I’m reading up on redirecting data to /dev/null and so I tried a simple test: If I try this: However, if I do this: That last solution is the desired solution, but what is happening with this 2>&1? My research so far suggest that 2 represents stderr and 1 represents stdout. So if I read it that way, it looks

Terminal edit command in a editor [closed]

Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 9 years ago. Improve this question I am coming from the postgres world, and am not very new to UNIX. My question is, if there is a way to invoke a editor from command

Advertisement