APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds RSS Feeds









Shell



xxd The commandline "xxd" is available in Linux and Mac OS X (though not on other BSD's I've looked at). The author says

The tools weirdness matches its creators brain. Use entirely at your own risk. Copy files. Trace it. Become a wizard.

It is similar to od, but doesn't try to do word interpretation. If what you want to see is hex bytes, displayed in the same order as they actually appear in your file, xxd is the tool.





Title Date Comments
Here files (shell scripting)   2012 10  2012/10/09 TonyLawrence
- Once again, I've been bitten by not having read the manual recently. This bite really annoyed me. -
No clobber scp - scp without overwriting   2012 10  2012/10/07 TonyLawrence
- Although you usually want scp to update files, there are times when you definitely do not. I wrote this script to avoid overwriting existing files. -
Capture and report (Bash Scripting)   2011 11 
- You've been asked to copy some jpg files to a USB disk overnight. That's easy enough - a cron job and a simple 'cp -a' will do that. But there is so much that could go wrong, isn't there? There might not be any files to copy or there might not be room on the USB disk. Somebody might have changed permissions on files or directories alreasdy in place, preventing overwrite with updated images. -
Auto Edge archive removal script   2011 09 
- The way I wanted Edge to work, was just like the days when we backed up to Tape. We would pull Master backups each night, label the tapes M-F, and take a SAT tape off-site for an extra layer of protection. When Monday rolled around, the new backup would replace the old Monday backup, rinse, lather, repeat. This changed when we upgraded to Edge 3.x, and started using the NAS. Once we had multiple servers with multiple jobs backing up to the same resource, and not having enough free space on the NAS because backups were piling up, I had to resort to manually deleting things (through edgemenu) on the NAS to free up space. This got old rather quickly, as I had to look down the long list of backup jobs, and determine which ones could be deleted. If I missed one day, the NAS would fill up, and backups would fail. -
Death of the command line revisited   2011 09  2011/09/10 TonyLawrence
- Five years ago I wrote a little blurb called Death of the command line. As it happened, that article was misunderstood by many who read it - I don't know if it was my fault or theirs, but somehow many readers ended up thinking I was either predicting the demise of CLI's (Command Line Interfaces) or hoping for that demise or both. Nothing could have been farther from the truth. I remain a big fan of CLI's and use them daily. And yet, just five years later and still at risk of angering yet another batch of folk who won't read carefully, I'm going to suggest that predicting the death of the CLI may not be such a bad bet after all. -
Higher resolution timers in the shell   2011 07 
- In the olden days, we'd pick up the current time from 'date' and store that. Then, after suspect part of the script, we'd run it again and calculate the elapsed time. Simple enough, but 'date' limited us to whole seconds. We had nothing in the shell that was tighter. -
Linux colors ls ––color command   2011 05  2012/03/03 anonymous
- Change default dircolors. Personally, I don't like colors in my shell. I think it would be fine as an option, but to have it as the default offends me and many other old Unix hands. -
Is sed dead?   2011 04 
- If you learn how to use sed, you get a bonus: the same editing commands can be used in ed and vi. -
The lowly ls command   2011 04  2011/04/20 TonyLawrence
- ls might have more flags than any other Unix command and operating system variance is wide. -
Finding Yesterday's Date   2011 04  2012/09/11 TonyLawrence
- How to find yesterday's date on Linux, Mac and any other Unix. -
Murder and mayhem - killing users processes   2011 04  2011/10/28 BigDumbDinosaur
- how to kill all of a specific user's user processes without "killall" - or select a subset to kill -
Slightly Scrambled - unsorting a file   2011 04  2011/04/05 TonyLawrence
- Here is a typical way to approach the problem. It uses Perl's associative arrays and (somewhat ironically) uses -
 
 
Kerio Connect Mailserver
 
 
linux set -o vi bash -->Re vi line-editing mode inbash?   1997-2004 
- Rather have vi style editing in bash? Ditch emacs style with this simple tip0 -
Using unblock and block with dd to add linefeeds and whitespace padding -->Re need file manipulation command   1997-2004 
- Using 'dd' to convert fixed length records to line feed terminated text or to pad ascii text with white space to creae fixed length records. -
exported functions shell scripting -->Re SCO shellscripts   1997-2004 
- Most shells support "exported functions". Understanding how to make functions available to other scripts can be confusing. -
Using the shell (Terminal) in Mac OS X   2002 12  2013/01/27 TonyLawrence
- Many Mac OS X users will not have any need to use the Unix shell that underlies their graphical interface. They are missing out. -
How can I recursively grep through sub-directories?   1997-2003  2012/09/05 P
- How to grep through sub-directories whether or not your Unix has recursive (GNU) grep. -
Getopt and getopts   2003 09  2012/12/19 TonyLawrence
- Both "getopt" and getopts are tools to use for processing and validating shell script arguments. They are similar, but not identical. -
Recursive chown   2006 03  2012/08/16 TonyLawrence
- 'chown -R' is smarter than you think. I had email this morning from someone using "chown" to fix up permissions on a directory. He had discovered "-R" in the man page but had run into a small problem... That succesfully changed the ownership of the "dot" files, but had an unexpected (to him) side effect: /usr was also changed. -
Controlling core files (Linux)   2005 03  2011/11/06 TonyLawrence
- Control Linux core files with ulimit and /proc templates. -
Bash in-process regular expressions   2005 09  2010/09/27 JonathanCross
- Bash acquired in-process regular expressions in version 3.0, but I never noticed, probably because most of the machines I'm using are Bash 2.05b. -
Finding large files   2006 12  2010/10/02 wilson
- Where has the space gone? Although it is getting harder and harder to run out of disk space, some of us still manage to do it. -
What is a zombie process?   1997-2003  2011/11/15 TonyLawrence
- Why can't you kill a zombie process? One of the early things people learn about Unix is that a "kill -9" is invincible- that a process must die if you send it a KILL (-9). However, that's not entirely true -
uname version -->Re UNIX version check command   1997-2004 
- Usually some variant of uname, often 'uname -a', but all sorts of other possibilies; t d epends on the Unix and in some cases even the specific version. -
Take Control of the Mac Command Line with Terminal   2009 05 
- Old-timers like me couldn't avoid being exposed to command line interfaces - that's all we had when we started Younger people and people who simply started using computers a bit later weren't necessarily exposed to any command line. Any computer they ever used had a graphical user interface and while it still may have had a command line available, there was seldom any incentive to use it. That apparent lack of any compelling reason remains true, but in fact understanding the command line can give you much more control over your computer and allow you to accomplish some tasks much more quickly and easily. -
Cron At and Batch   2000 01  2012/06/11 TonyLawrence
- Cron, Batch and At, including explanations of why it might not be working -
Bash HISTCONTROL   2006 05  2011/04/07 TonyLawrence
- controlling bash history. There are actually several values HISTCONTROL can take. On newer bash, it can be set to "ignorespace", "ignoredups", "ignoreboth" or "erasedups". Bash 2.05 doesn't have "erasedups". -
Controlling Linux colors in vi (vim)   2005 03  2011/04/13 geedoubleya
- The Linux colorizing fouls things up royally. You can shut off command line colorizing by editing /etc/DIR_COLORS and changing COLOR tty to COLOR none or (less drastically) by removing the TERM ansi line from the same file (which removes colorization for ansi but doesn't affect console use). But that still leaves vi messing things up. The fix for that is to add -
./bashrc doesn't run automatically   2005 04 
- my customer has played with webmin and did something to logins so that some users .bashrc doesn't get executed. -
Continuation Lines   2006 06  2010/05/27 anonymous
- There's been a long standing Unix convention of breaking long lines with a "\" to make them easier to read. You'd almost always see this in files like /etc/printcap, but there are plenty of other places where this convention is used. -
How do I make environment variables global?   1997-2003  2010/02/09 anonymous
- Once the variable is exported, you can change it's value and do NOT have to export it again. -
Using color in shell scripts (Linux, Mac OS X)   2009 11  2010/01/03 BigDumbDInosaur
- Color is tricky. Displays can be bad at it, people can be color blind... using colors can make text hard to read - I don't like using color in scripts. -
Bash shell $PIPESTATUS   2004 06  2011/04/04 TonyLawrence
- PIPESTATUS array holds the exit status of your last foreground pipeline commands. -
Sort -u vs. uniq   2009 11 
- Don't tie yourself in pipeline knots with either of them; learn to use each of them appropriately and your scripts will be easier. -
using bash select   2005 09 
- The description of select in the bash man page is enough to give anyone a headache: -
Bash typecasting   2006 08 
- Bash has typecasts - but only sort of and your scripts can easily break because of it -
sandbox-exec (Mac sandbox wrapper)   2007 12 
- Sandbox-exec can protect yoy from unknown binaries -
File date comparison   2005 11 
- For this example, we'll use the case where a file shouldn't be overwritten if it was created or changed today. But what does "today" mean? -
Awk vs. Perl   2009 11  2012/08/15 TonyLawrence
- Sure, I used to use awk. When I used it, you weren't likely to find Perl onmost Unix systems, so for a lot of text mangling, awk was at least easier than writing in C or anything else. It did the job, and you'd get used to its quirks. -
zip vs. gzip, compress, pack   1997-2004 
- The algorithm used by `gzip` is one of the ones used by `zip`. `zip` supports several algorithms and tries to choose which one will produce the smallest output (actually the Unix port of `zip` just uses one algorithm, called "deflate"). -
Find with -execdir   2009 02  2011/10/25 TonyLawrence
- This article discusses the "execdir" option to "find" and the use of "\;" or "+" to terminate the arguments supplied -
Prevent deletion or moving of files   2009 10 
- You need to let users create files in a common directory, but you don't want them to be able to delete other's files. Or you've put certain files, directories or symlinks into a user's home directory and don't want them to be able to mess with any of those. What can you do? -
write to all users -->Re Broadcast message   1997-2004 
- The "wall" command does that. Login as root, type "wall" <ENTER>, then whatever you want to say (multiple lines are OK), follwed by <ENTER> and then CTRL-D -
trapping error in bash script 'trap error ERR'   1997-2004 
- If a sigspec is ERR, the command arg is executed whenever a simple command has a non-zero exit status. The ERR trap is not executed if the failed command is part of an until or while loop, part of an if statement, part of a && or || list, or if the command's return value is being inverted via !. -
opensnoop (Mac file open watcher)   2007 12 
- opensnoop is powerful stuff, but it's easy to misuse. There is a large pile of pre-made Dtrace scripts available on Mac OS X Leopard. -
SSH_CLIENT, SSH_CONNECTION (OpenSSH Variables)   2005 05 
- 2005/05/31 SSH_CLIENT, SSH_CONNECTION (OpenSSH Variables) -
extglob (extended pattern matching bash)   2005 05 
- 2005/05/25 extglob (extended pattern matching bash) -
shell script read password without echo -->Re Readinginput without echo   1997-2004  2013/02/14 anonymous
- shell script read password without echo -->Re: Readinginput without echo -
User Friendly Date Script   2001 06 
- A more user-friendly command line front end to changing the date and time on Unix and Linux. -
Using the Korn Shell   1997 
- A.P. Lawrence, Linux/Unix Consultant-Korn ShellBasics -
 
 
Kerio Control Firewall
 
 
timeout of ping -->Re timeout of ping   1997-2004 
- The new flag, carped from BSD, means 'stop the whole ping session after this much time, regardless of how many packets have been sent or received, or current success status'. -
xxd   2006 05 
- If what you want to see is hex bytes, displayed in the same order as they actually appear in your file, xxd is the tool. -
Wrapper scripts   2006 12 
- When a command doesn't quite do what you want. wrpaaing it in a tiny shell script is often the most simple answer. -
Kermit 95 2.1.3   2003 03  2011/03/31 TonyLawrence
- This is a review of an ancient terminal emulation product and is only left here for historical purposes. -
Removing duplicate files   2009 04  2010/05/22 binaryman
- This Perl script considers a file to be a duplicate if it has the same name and the same number of bytes. THAT COULD BE A VERY BAD ASSUMPTION. -
Perl directory listing   1997-2004 
- Learning Perl basics to produce 'pretty' directory listing with 'File::Find'.: A "pretty" or custom directory listing is a good place to start developing your scripting skills if you want to. There certainly are utilities that do pretty listings, but the advantage of rolling your own is that you can do EXACTLY what you want and gain some useful skills while you are at it. -
Basic Scripting   2001 02 
- Scripting at its simplest is telling the computer what you want it to do by putting the commands you want to use into a file and running that file instead of typing the commands. -
drutil - command line access to CD's and DVD's   2005 12 
- Mac OS X has a wonderful little drutil tool (10.3 and up only). It can tell you all sorts of things about cd's and dvd's, from the simplest inventory to 'more than I wanted to know' -
case conversion in bash script??   2006 08 
- Now I want to convert the content of VAR ($VAR) to lowercase. How can I do in bash. -


More Shell articles

pavatar.jpg
book graphic












Have you tried our Tests?