What do you want?
January 7th, 2008
I have not posted since October in part because I don’t know _what_ to write about? I have a few topics in the works, but please please please, if you have any ideas, comment on this post or send me an email. All suggestions welcome!


January 8th, 2008 at 12:26 am
I recently needed to append a file to itself many times, in order to bulk up a dataset. I suspect there are many better ways, than what I chose. Since it was done in the context of this page
http://www.runblast.com/wiki/index.php?title=Hmmer
maybe you’ll spot other places my bash looks clumsy.
January 8th, 2008 at 6:13 am
cariaso: try mkfiles, or plain old dd.
original post: maybe you could post about any neat utilities that you made for yourself? I have a few of my own that could possibly be useful to others too.
January 8th, 2008 at 11:41 am
How about starting at the top?
I view bash scripts as a programming language, so I start to look for
control loops, if-then-else, repeat-until etc.
If I get scarily confident I start repeating stuff over all the files in a directory!
On good days I go googling on how to use sed repeatedly… but that’s not often.
January 8th, 2008 at 8:58 pm
You can blog about some cool scripts used by you.
You can blog about other scripting languages like perl also …. if you like
January 8th, 2008 at 9:00 pm
You can also explain a bit about environment variables !!
January 8th, 2008 at 9:11 pm
Thanks guys this helps me get a general feel for what people are looking for! If I have a few topic ideas, it is easier to write.
If you have a specific question, shoot me an email. I usually find time to help out and then convert it to a post.
January 9th, 2008 at 9:45 am
I have no specific request but just wanted to say that I’ve been checking your site regularly and am glad to see that you’re back to posting.
January 9th, 2008 at 10:45 am
Thanks! That is great to hear…. I think I will be posting in a regular manner now. I am doing more Linux work.
January 10th, 2008 at 8:33 pm
cariaso,
I have never actually seen anyone use pushd and popd! I’ll make those commands an article. They can certainly be exceedingly useful when writing scripts….
January 14th, 2008 at 12:39 am
Shell scripting please…
January 15th, 2008 at 5:11 am
I use pushd and popd quite a bit, just at the command line. When I need to interrupt the work I’m doing in one directory, and remember to realise that I’ll want to come back there, it’s handy.
Once upon a time, I had my bash prompt set up to display a digit indicating how many pushd’d levels I had in the current session. I still do have my prompt displaying the first letter of each suspended task - so if I’ve been into emacs, hit Ctrl-Z, and also been into less and hit Ctrl-Z, then my prompt will go …]el> . Perhaps other useful tricks to include in a prompt?
I only very recently learned about the -i option to sed, to modify-in-place. Little tricks like that are the best kind of thing on this blog
January 15th, 2008 at 8:19 am
Alex,
Thanks for your comment! Prompt modification is a good idea. Also, yes, I love the -i option of sed, but I use perl -i to do search and replace for a variety of reasons. I’d like to write an updated perl one liners article as the current internet sources are pretty old.
January 21st, 2008 at 9:05 pm
[…] asked “What do you want” and you said scripting. Which is good, because I have felt like scripting […]
January 22nd, 2008 at 3:38 am
A belated one, based on a problem yesterday. Again at the simple? level.
Script escaping? I wanted to echo “backup is at $1_backup” except that
the underscore needed (sort of) escaping?
How about a reminder for the newbies on escaping, variables etc?
TIA DaveP
January 30th, 2008 at 1:05 am
I’ve been learning tidbits about history substitution lately; I’d never used much beyond !!, really. But substitutions like !$ and modifiers like :p, :t, :h, and :s/foo/bar are priceless. What else could I benefit from knowing?
I’ll echo the calls for good ways of using pushd and popd. I use them all the time, but the stack seems more cumbersome than it should be. Expansions like ~+1 are a godsend, in any case.
Cheers!
-Steve
February 4th, 2008 at 9:10 pm
Here are a couple ideas of things I’ve haven’t gotten around to looking into:
I’ve been using TMOUT to log out consoles I leave sitting around. But on timeout I wanted to run a program instead of logging out. (like a screen lock program such as cmatrix) The problem is that on TMOUT, it logs out and kills all running jobs.
Possibly not directly related to bash but are there simpler alternatives to screen? Possibly bash instances we can reattach to?
How about a 10 second explanation into the initialization of bash. Which gets called when always confuses me with .bash_profile & .bashrc. What about a debug mode that echos which files are being read?
I have yet to find a features matrix between all of the shells. e.g. bash vs ksh vs csh vs others etc…
No one has implemented bash ‘themes’? Such as bash init files that I can source to set font colors, prompts, enable features etc???
Top 10 bash tweaks would be cool.
That’s all I have as a laundry list of things I haven’t had time to look into…hope it helps. I’d be very interested to see your thoughts on the above.
Regards.
Peter Lombardo
February 7th, 2008 at 12:10 am
I have a bunch of hacks at my site: http://sizone.org/~math/hacks check them out. Pretty crappy coding there, but stuff works
as for prompts, i have a nice huge monitor now and lose my prompt up the screen trying to figure out where the last cmd i ran started on screen, so I make it bold:
PS1=’ \[33[1m\]\u@\h `date +%m%d\ %H%M%S` \w>\[33[0m\]’
at some font levels, bold doesnt look good, so I use screen’s attrcolor b ‘-b M’ to make all bold magenta, for eg. makes prompts easy to find!
Problem with this prompt is that bash when it goes to erase stuff INCLUDES the prompt’s literal definition of number of characters to delete when clearing backwards, whereas the displayed # of chars is different (all those escapes dont display), so you sometimes get a mess - a WORKAROUND FOR THAT would be great, if you have one.
February 7th, 2008 at 12:12 am
wow my prompt didnt work well, somehow the processing of this text input box ate my 0!
ill insert spaces between every char
PS1=’ \ [ \ 0 3 3 [ 1 m \ ]’ to turn on bold.
March 4th, 2008 at 11:41 pm
hi,
and another i tried reading known_hosts file and its all encrypted on my box.
i have a request for help. here is a typical use case.
i have access to some 20 machine with different long names. i was trying to get autocomplete feature for hosts where i have already once been to. (from .ssh/known_hosts obviously) but could hook it up. because i don know which hook to put and where
can you please help with it.
thanks