`cd -` to go back to the previous directory. Saved me LOTS of time over the past few months.
Unix Commands I Wish I’d Discovered Years Earlier
141–150 of 259 posts
Re: Unix Commands I Wish I’d Discovered Years Earlier
#142history | grep I use this for rsync or rdesktop when I have forgotten the long list of options & directories etc I also use ctrl R at the bash prompt but that only gives me the most recent match.
Are you sure, I'm using BASH on Kubuntu and I get previous matches by repeated use of ctrl+R.
Actually inspired by a previous post here I made a script "hs" that searches archived history files and shows me all past match lines. Before that I did what you do now.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#143`cd -` to go back to the previous directory. Saved me LOTS of time over the past few months.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#144Earlier quoted context omitted.
xxd is on OSX, but not on FreeBSD. Under FreeBSD, I always use 'hd somefile.bin'.
I've been told before that `od' is the most portable, although I prefer xxd in virtually all situations.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#145Earlier quoted context omitted.
If you don't want to clog up your terminal, try 'less' and then hit 'F' to follow.
Better yet use 'less +F'. It's as easy to remember as tail -f. The advantage of using less here is that you can easily interrupt the tailing (ctrl-c). For example, to search. Then just hit 'F' again to restart tailing. But now your search pattern will be highlighted as the data streams by.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#146 "Toggle hex edit mode
nmap h :call ToggleHex()
let g:hex_mode_on = 0
function! ToggleHex()
if g:hex_mode_on
execute "%!xxd -r"
let g:hex_mode_on = 0
else
execute "%!xxd"
let g:hex_mode_on = 1
endif
endfunction
Stick this in your .vimrc, type something, use \h to convert it to hex, change a value, then \h to convert it back and observe how the text has changed. Not super useful, but a neat party trick.Re: Unix Commands I Wish I’d Discovered Years Earlier
#147Earlier quoted context omitted.
'screen' is absolutely crucial with ssh, too.
I find tmux to be a bit more pleasant to work with. In the past it didn't do reflowing upon resize, but it does that now.
nohup time whatever >whatever.out &
because so many programs behave differently when attached to a tty (like prompting for input) and I just want a plain text log that says when it succeeded or where it blew up.Re: Unix Commands I Wish I’d Discovered Years Earlier
#148Earlier quoted context omitted.
This is a nasty hack where it is counting the output from find. What do you do when find cannot handle the sheer number of files, argument too long from the linux hardcoded MAX_ARG_PAGES We need a dedicated utility that counts inodes.
I think you are confused — at no time are any files passed as arguments in the command "find . | wc -l". Also, to count the number of files in a directory, you need to do readdir(), which will get you the names. Then, to see if any of them are directories to be recursed into you need to stat() the names individually. This is all "find" does. How , I'd very much like to know, is this "a nasty hack"?
All we want from find is "count the number of inode entries in this tree branch that are type f". No formatting, no output, just count. That has to be much more efficient.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#149Earlier quoted context omitted.
Still about ssh : "typing a password on your local machine once, then using a secure identity to login to several remote machines without having to retype your password by using an ssh key agent. This is awesome. " Sounds awesome, but I really didn't understand what he means. Is he talking about using a certificate (-i option) to log in ?
Yeah, you have a cert set up and put the public cert in the identities file for each server you want to connect to. Then just SSH into each box with agent forwarding ('-a' I think, but you're best to check that). So you'll need to create an SSH cert first: ssh-keygen -b 4096 -t rsa -C "$USER created on $(hostname)" -f $USER.key Keep the private key, that's essential you keep this safe as it's literally your key to ac…
"ssh-ebT23030"
Meaning that anyone with root access who know the other machines that someone is accessing as well as their username can access those machines.
I've seen cases where in abnormally terminated sessions that file stays around instead of getting deleted when the session ends.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#150There are some other useful commands for organizing the stream of datas for pretty printing: column - columnify the incoming stream into columns pr - set up incoming stream for pretty printing including columnification along or across the screen tr - sanitize input, collapse several delimiters into one
echo $PATH | tr : '\n'