Reputation
1,540
Top tag
Next privilege 2,000 Rep.
Edit questions and answers
Badges
4 11
Newest
 Informed
Impact
~78k people reached

Dec
3
answered advanced sed print + replace
Dec
2
comment advanced sed print + replace
You're right, of course. Started out brainless, continued that way. My apologies.
Dec
2
comment advanced sed print + replace
Oh, god. That's brainless enough I'm just going to delete it. Here: sed -ni '/test/w /dev/tty s//best/g; p' (w/ a newline after tty)
Nov
8
answered bodhi linux deleted lxterminal
Nov
8
comment I need to make a file undeleteable, but allow it to be modifiable and renameable
You can set the sticky bit on any directory you want.
Oct
23
comment “render” textfile with carriage returns (^M) and save output to file
Given the \r usage here sed 's,.*\r\(.\),\1,' or maybe awk -F$'\r' '{print $NF}' should do it. But in general showing text as your terminal emulator rendered it means running it through your terminal emulator, xterm -e cat file /dev/tty will at least not litter your main scrollback buffer.
Oct
10
comment Exit vim more quickly
@CodeMedic It's far and away the fastest if you've got nno : ; and nno ; :, though. (plus vno the same). I was dubious about the swap, but you'll never go back. :nno ,: :silent! unmap :<CR>:silent! unmap ;<CR> and :nno ,; :nno ; :<CR>:nno : ;<CR>:vno ; :<CR>:vno : ;<CR> support the odd yap@" and such.
Oct
8
comment How do I clean up vi and reinstall it completely?
Looks to me like you're using homebrew, does this link help?. This is from googling "/usr/local/Cellar" which I'd never heard of before. Perhaps your python is backlevel? I don't know.
Oct
8
comment Do hard links count as normal files?
@mikeserv See, I can spell pty and pts, and probably even ptmx on a good day, but that's about it. :-) at least the 5,0 node works everywhere I can find, it's the controlling-tty device type. I got it with just ls -l /dev/tty, guess I got lucky there.
Oct
8
comment Do hard links count as normal files?
@mikeserv but to actually answer your question (sorry for the wot), yes, every link is just another way to get to the underlying object.
Oct
8
comment Do hard links count as normal files?
@mikeserv A socket's a purely runtime entity. socket() creates an actual socket, bind() gives it a specific name, connect() connects a socket you made to some named socket. Different kinds of sockets use different kinds of names, e.g. Internet sockets use Internet addresses, but they all share common API (including read() and write(), it makes me sad that you can't open() a filesystem socket and have the OS or libc do socket() and connect() for you). man 7 socket has more, all the networking protocols do make for a fidgety manpage.
Oct
8
comment Do hard links count as normal files?
@mikeserv It's the make-a-socket program above, it just drops a socket link named "socket" in its current directory.
Oct
8
revised Do hard links count as normal files?
only non-symbolic links keep inodes around
Oct
7
revised Do hard links count as normal files?
added 69 characters in body
Oct
7
answered Do hard links count as normal files?
Oct
6
comment convert wav to flac with tags
Nice. I think you want ${file##*/} to handle a/b/c.wav
Oct
5
comment Find 2nd Occurrence of string from the end of file
Wow. I'm claiming actual genetic defect. I can't seem to learn not to keyboard-to-editbox waaay too often. Naaah, I leave "exercises for the reader", yeah, that's it. . . . anyway, set -- $(sed -n /Important/= $file | tail -2); sed -n $1,$2p $file works. @don_crissti I'm thinking about pipeline use, adding an extra writeitall-rereaditall trip through a filesystem is generally worse than maybe having to buffer it all in the first place. But I see your point. If it gets really big, the filesystem cache might be more capacious and perform better than swap.
Oct
4
comment Find 2nd Occurrence of string from the end of file
To avoid buffering lines you know immediately won't be needed, if you've got GNU sed you can put in a leading '0,/Important/ //!d' The 0, range starter (treating the block as already started) is GNU.
Oct
4
comment Find 2nd Occurrence of string from the end of file
Oooh, I like this one. set -- $(sed -n /Important/=; tail -2) $file; sed -n $1,$2p $file On a big file two-pass might be a problem.
Oct
4
comment Find 2nd Occurrence of string from the end of file
This answer doesn't satisfy your constraints as stated, but I think what you're after is really "The last two "Important" lines and everything between them, i.e. only the last "Important" block, not that block and everything that follows. It's easy enough to fix up the regex's here if I got that wrong, change the [^\n]*s to .*. Because of leftmost-longest, that change will also leave nothing for any trailing .* to match.