Shell Script ProgrammingHow can I keep a compressed Linux archive up to date?We have a situation where we need to keep a ZIP archive of some data files available on our Ubuntu Linux server so that our satellite offices can grab the information through slower data lines. Problem is, the underlying files change 2-3 times a day. What's a quick, efficient way to only rebuild the ZIP archive file on our Linux system if a file's changed, but leave it as-is if everything's stayed the same? CGI Scripts and Web Site ProgrammingHow do I find out what searches people did to end up on my Web site?I've been trying to figure out whether there's a way that I can automate digging through the "referrals" on my site so I can see what searches people did to end up on one of my Web site pages. I'm running a Linux server and have Apache installed, so I get a huge log file with tons of info. But what I'd love is a simple script that will let me get email once a week with a sorted list of what searches people did to get to me. Doable? Shell Script ProgrammingHow can I convert map addresses into latitude longitude?I'm trying to write a shell script that will accept a street address and output the latitude and longitude of that address, for geocache purposes. How can I do that? Shell Script ProgrammingHow can I bulk rename Apple iPhone screen captures?As part of my work, I take tons of screen captures on our test Apple iPhone for documentation, but my boss wants me to use SEO friendly file names and it's a huge hassle to rename them one by one. Is there some sort of script I can use on my Mac to fix things? Shell Script ProgrammingHow do I analyze word use in a document or book?I've got a bet with my husband and you need to help us settle it. I was reading Jane Austen's "Pride and Prejudice" and he said "I bet you $20 that "pride" shows up more than "prejudice" in that book." I think he's wrong, but have no idea how to figure it out. Can you help? Shell Script ProgrammingHow can I count letters in a text file?Hey I want a Perl script that reads a file and sends me the number of occurrences of the alphabets in that file... Could you please help me? Shell Script ProgrammingHow can my shell script test server status?i am in big problem so please help on it. below i write the scripts, i don't know it is correct or not, but i want write the shell script for. In particular machine need to check all process are running or not, and we need result to display in the web page like server name = running, not only single server we have so many servers so, result like in the web page: server1 = running like that so many server we have and one more thing is need show in web page with colors and fonts. please help on it! Shell Script ProgrammingHow do I read prior lines in a text file?I want to compare a line in a file with zero(0) and if its more than zero i want to print the prior two lines, can u please help me in solving out this... please Shell Script ProgrammingCan I automate craigslist searches?I want to know if there's some way to automate searching the craigslist site with a shell script or similar so that I can keep an eye on it and know when certain rare auction items show up for sale? Shell Script ProgrammingUpdate to Wicked Cool Shell Script #62: define.shThis is regarding script #62 (define a word): Looks like WordNet has changed their online version again and I tried the following replacement for the url= http://wordnet.princeton.edu/perl/webwn?s= But the script doesn't return anything but goes back to the prompt. I tried the url with a word in lynx and I got the source. Could you push me in a general direction? Shell Script ProgrammingHow do I step through numeric values in a shell script?Please, gimme a advice how to correctly use loop "for i in `seq 1 10`" for Mac OS X, echo $SHELL->/bin/bash, because when I write simple strip: for i in `seq 1 10`;do echo $i;done it outputs -bash: seq: command not found. Shell Script ProgrammingCan I send Twitter updates from the command line?I'm becoming a big Twitter fan, but as a Linux user, I find it darn frustrating that most of the apps out there are for Mac and Windows users. I mean, I'm used to it, but is there at least some way to get to Twitter from the command line? Shell Script ProgrammingHow do I create a custom stock market index?My boss had a great suggestion for our local business web site: create a stock index like the S&P 500 that's just comprised of companies in our area. He said we should add it to our site but I honestly have no idea how to do that. Help! Shell Script ProgrammingHow many Friday the 13ths are there in a given year?I'm studying Unix, and i need help writing a script. The script requires that it outputs the number of months and years from January 2007 to December 2017 inclusive that have a Friday the thirteenth. Shell Script ProgrammingBug in shell script using awk to read /etc/passwd?In your book Wicked Cool Shell Scripts, on p. 115, Script #40 Reporting Disk Hogs, on the 8th line the second part of the line reads: awk -F: '$2 > 99 {print $1} ') I am very new to shell scripting, so I am probably just not understanding how this line should be interpreted. In my Linux class, I have been learning that in the /etc/passwed file the 1st field is username, the 2nd field is password (x), and the third field is the UID, so wouldn't the $2 above really be $3 so that the script would be checking to see if the UID field, which is field 3 is greater that 99, not the password field,which is field 2? Please let me know, since this is confusing to me. Thanks for your help. Shell Script ProgrammingHow do I turn a command line into a shell script?I've been experimenting with mencoder to convert my AVI movies into a format that I can download onto my cellphone and finally found a site where they explain the various parameters needed for the mencoder program to get it to work. Problem is, they're a pain to type in each time. How do I turn an ugly command line invocation into a nice shell script? Shell Script ProgrammingHow do I compare float / real numbers in a shell script?Hi i am trying to comapre numbers for the biggest among double type of numbers. For example: 0.254, 0.255, 0.564, 0.984, 0.556, 0.6566, and 0.5666. I'm using the following script code: if [ $max -lt $i ] But they all give the error message "integer expression expected". Help! Shell Script ProgrammingHow can my shell script test to see if it's already running?I have a script that does an ftp from a SCO UNIX server to windows server to get files from the windows server. The script is set in the cron to run every xx minutes. Sometimes the script will hang and leave a process running. This can bog down the UNIX server. I want to be able to do two things. 1. I want to make sure that the script doesn't hang - so it should terminate after xx minutes (the files are very small that it is getting). And 2. I want the script to test to make sure that it is not already running, before starting again. THANKS Shell Script ProgrammingHow can I count executable binaries on my Linux box?I've been looking at your script to count executable binaries in the book Wicked Cool Shell Scripts and I think that there's a problem in the script. Specifically, what happens if I have a directory in my PATH more than once? CGI Scripts and Web Site ProgrammingCan I create an Apache image directory browser script?I run a fairly busy Web site with a variety of different image directories. The problem is, Apache shows directories in a fairly rudimentary way which makes it quite difficult to find a specific image if I don't remember its name. Is there a better way with some sort of shell scripting? Shell Script ProgrammingHow can I time portions of a Linux shell script?Just picked up your book Wicked Cool Shell Scripts and already have one quick question: While working on the startup scripts, I would like to place log timers at certain portions of scripts. Is it possible to log point A at he beginning of a section, do the processing, log point B at the end of the section and then log B minus A so I know exactly how long a section took to process? d) None of the AboveDo most music CDs have 12 tracks?This might sound like some wild conspiracy theory, but I'm looking at my music collection and it sure seems like most of them have exactly 12 tracks, no more, no less. Is there some marketing reason this would be the case, or am I witness to some great conspiracy? :-) Shell Script ProgrammingScript to rename thousands of files and directories?I need to rename thousands of files in MacOS, buried in subdirectories, changing " " to "_". I've found a ton of scripts using Google that purport to do this, but none of them actually work right. Can you please send me a script that does this? I also tried Automator, but it doesn't recurse into subdirectories. Filenames may have multiple spaces (eg "Holidays/Christmas/Gifts & Stockings (A - G)/stocking.png"). Directory names may have spaces, too. Shell Script ProgrammingHow do I strip leading zeroes for math in a shell script?I have a file containing lines of data that are amounts padded with leading zeros, similar to the snip below. 0000000004 Using a shell script, how can I add up a column of numbers contained in lines when BASH interprets the numbers as octal when I do in-line math? Shell Script ProgrammingHow do I identify files changed during a specific month?i am having difficulties writing a script to back up files which have need modified during the month specified in the option. The command is: Shell Script ProgrammingHow do I increment IP addresses in a shell script?I need help with a shell script! I want to prompt someone to enter an IP address the automatically increment it and output the sequence of that address and its following addresses, but I don't know how to do that: when I try to increment a value like "10.10.10.27" it fails because it's not a number. Shell Script ProgrammingString comparisons don't work in shell scripts?I'm a bit baffled. I'm trying to compare string variables in a shell script to figure out if one value is lexically less (that is, would appear earlier in the dictionary) than another, but it doesn't seem to work at all? Help! Unix and Linux HelpHow can I run an app if another app is running?I need to run a Unix application if a different application is running, from within a shell script. How do I do this? Shell Script ProgrammingHow can shell scripts check user ID?We have several different shell scripts that we run on a daily basis. Sometimes one of the computer operators will execute the shell script as the wrong user (Root for example). This screws up the permissions and owenership on all of the files that the script just touched!!AAAARRGGGGGGHHH! I am looking for a way, when the script fires, to see who is running it. Shell Script ProgrammingHow do I delete all but one directory in Linux?I have a series of boxes (over 1,000), that have the same directory that has been used over time as a dumping ground for various 'stuff', and now I need to have them cleaned up, save one sub-directory. What I need to know, is there a way to create a script that will allow any user to delete everything (hidden, directories, links, etc.) from a particular directory, except one sub-directory. Shell Script ProgrammingAutomating SSH with a shell scriptI am trying to write a shell script for automated ssh. vairable user and passwd have initialized correctly, but when I use the following it still prompting me for the password. ssh -l $user cisdevapp1 I have also tried the following ssh -l $user cisdevapp1 < and no luck. Please help? Shell Script ProgrammingHow do I read lines of data in a shell script?Dave, where can I find a bash script that can read data from a file; the information should be separated by tabs or commas for easy pickup, and can only be accesed by a row. Shell Script ProgrammingDate math in Linux shell script?Within a Linux shell script to be used as a cron job, how do I calculate the current date, the current date - n days, and the current date + n days ? This script is to be used to partition an oracle database, and automatically drop old partitions (n+1) and create a new partition (n+1). Shell Script ProgrammingPrompting users for passwords in a shell script?How do you write a bash script for example, a user logins to the server's shell, then I want a bash script that will prompt him a password to verify he is a legit user not an intruder. The answer of the password will be located in a file (for example: /etc/verify). If the user not able to type the correct password 3 times the server will kill that connection and bans his IP address from the server. Shell Script ProgrammingShell script to scrape /etc/passwd data?I am working on a script where I would like to grab the usernames out of the passwd file and add a emaildomain then ftp it. For example I would like to pull the usernames for all users in /etc/passwd and add @domain.com the ftp it to ftp.domain.com . Can you help? Shell Script ProgrammingHow do I rotate files in Unix?On Solaris I have cron job which creates some log files and it puts it under a directory, this directory name is created based on system date for example directory name are like 08162005, 08172005 so on.. What I need is I want to do a rotation for these log directories every 14 days since these are directories with system dates, I am having little trouble getting this done, Is there any way you can solve this for me?? Shell Script ProgrammingHow do I customize a script from "Wicked Cool Shell Scripts"?Regarding script #41 (calculating available disk space), out of your book Wicked Cool Shell Scripts, I am unclear how I can have this script calculate the free space on one specific drive, namely /Volumes/Documents HD in my case. I'd also love to know how I can automatically email the results of this same script, say every 24 hours. If you could kindly point me in the right direction, I'm sure I could figure out the rest! Shell Script ProgrammingSelect range of users from /etc/password in a script?I am working on a script where I would like to grab the usernames out of the passwd file for a defined range of UIDs. For example I would like to pull the usernames for all users in /etc/passwd that are in the range of 5000-5999. Can you help? Shell Script ProgrammingHow do I re-redirect stdin in a Unix or Linux shell script?Hi Dave. I'm trying to create a shell script in HP-UX Unix that looks like this: while read usrname do lsh $usrname done < $fileand in lsh I added some error checks. If one occurs I ask the user to correct their input, but the code didn't work that way and it continues to read another line from file usrname. I don't know how to stop in while loop, to get input from the user. What's the trick? Shell Script ProgrammingRedirecting input in a unix shell script?I have several SCO Unix script that read a parameter from user input or otherwise I put the param within my script, such as ftp scripts and so on. How can I read those parameters from a file instead? Example: I write an ftp script that will connect to a remote location and bring files, right now I write the same script as many times as I have a remote location, but I'd rather substitute the open xxxx from a file. Also if it is an interactive script and the user need to send to more than one location then I need to be able to collect all the location numbers then read then into my script. Shell Script ProgrammingI hear that your shell scripting book won an award?Dave, I heard that your book Wicked Cool Shell Scripts won some sort of award or the other? Do tell, what's the story with that? Shell Script ProgrammingHow do I rename hundreds of files at once?
Dave, I'm in a bit of a pickle. Like you, I'm an author, and as I wrap up my latest book project, the development editor sent me a note saying that all the figures I've submitted, all 217 of them, are incorrectly named and need to be fixed. Augh! The naming scheme I'm using is FIGxxyy.TIF where xx is the chapter number and yy is the figure number. To make it a bit more complex, sometimes I use a three digit figure number and other times I use a two digit value. I need all the files to be called xxFIGyyy.TIF. How do I do that without going crazy?
Shell Script ProgrammingCan I selectively remove Safari favicon icons?
I've been slowly adding all the nifty features to my new Web site and am going a bit crazy with Safari. I changed my favicon.ico favorites icon for my Web site, but Safari insists that it's not right, though when I view the site in Firefox, Camino or any other browser it's fine. How do I get Safari to be happy?
Shell Script ProgrammingCan I extract all my Safari bookmarks with a shell script?
Alright, this is pretty geeky, but is there a way I can grab all my Mac OS X Safari bookmarks using a shell script so I can manipulate the data? I've peeked into the bookmarks file and yow, it's one hairy data file!
Shell Script ProgrammingCan I use my Palm Desktop address book data in shell scripts?
Dave, I have a pile of addresses in my Palm Desktop address book on my Mac, but I'd really like to be able to use them from within some shell scripts, particularly to be able to build a quick reference of names and phone numbers. Is that even possible?
Shell Script ProgrammingDoes -prune work like -maxdepth in Unix "find" on AIX?
Dave, I purchased your Wicked Cool Shell Scripts book a month or so ago (great book), and have used it to "learn by example" in writing some shell scripts, as I've a long way to go in this area.
I need to rotate logs on an IBM AIX 5.1 Unix box, and tried using your script #55, rotatelogs for this but it didn't work, as -maxdepth is not supported in AIX's find command. So, I commented it out, and it worked, but also rotated everything in the subdirectories as well (no problem...backed up directory first, then restored). I am trying to get it to work using -prune which my search in Google found to be a good fix for the lack of maxdepth, but it's not doing what I want. Help! Unix and Linux HelpWhat's acceptable syntax in Unix and Linux sh scripts?
Dave, I ran across your sites and Wicked Cool Shell Scripts book while trying to convince myself that `sleep 0` is a valid and relatively portable command to use freely in my unix shell scripts.
I looked at a few of the Bourne shell scripts and they seem to use constructs like $( ... ) and $(( ... )) which are not standard Bourne shell (to my understanding). So I actually have three questions, rather than just one:
Shell Script ProgrammingCan I keep track of my Amazon book rank with a script?
Dave, do you happen to have a script that will pull Amazon.com hourly
sales rank data for 1 - N ASINs and save into either a CSV file or a
database?
Shell Script ProgrammingHow do I write a full-screen bash shell script?
Dear Dave: I am trying to write a full-screen utility that
displays the permissions of a directory and all the
directories in the directory's path. It should also show
other information about the directories, as the cursor
is moved up and down the list of directory names.
Can you offer me some pointers to get me started?
Mac OS X HelpCan I list my iTunes Library by number of albums?
I've spent a lot of time poking around with my extensive iTunes database and had lots of fun figuring out different ways to address my needs with a fully digitized music collection. When a reader asked whether there was a way to just list those artists in her iTunes collection for whom she had more than one album, I thought "ah, this sounds up my alley", and so it is.
Shell Script ProgrammingCan I track an RSS feed with a shell script?
More than once, readers have written to me, asking if it was possible to track an RSS feed from a Weblog or news site with a shell script. Sounds kinda wacky, but in fact, it's a very good use of a shell script, as the following rather extensive entry -- including source code! -- demonstrates. If you're a bit confused by the following, you might want to consider picking up a copy of my best-selling Wicked Cool Shell Scripts.
Shell Script ProgrammingHow do I create a group-based disk usage script?
A reader writes:
"I've been reading your book Teach Yourself Unix in 24 Hours and learning a lot, but I'm stuck on a disk usage problem. Suppose there are 5 people (A, B, C, D, E) in our group
and they share the same directory called "group." The total capacity of this
directory is 100 GB. I'm looking for a program/command/script that can be
run to generate the following space usage update:
This is an interesting question, so let's dig into it and see what we can figure out...
Shell Script ProgrammingHow do I create a shell script on a Macintosh?
A reader writes:
I've started to go through your shell script book Wicked Cool Shell Scripts but there is still something I'm unclear on. I'm showing my ignorance here, but how exactly do you save a shell script so you can use it later?" Shell Script ProgrammingTweaking FTP scripts to fine-tune their behavior
A reader writes:
I have your Wicked Cool book and love it. I am new at scripting and it is helping a ton. Question. I need a script to use the timestamp feature (ingenious by the way) of Script #83 but "get" the files from a remote server like Script #82. Do you have one modified in such a way? Shell Script ProgrammingWhere can I get free tips about Linux shell script programming?
It's not uncommon for me to receive email from people asking for information that's covered in one or more of my books, and this morning I received a message asking about good places to go online to learn more about shell script programming. My answer, of course, is to buy a copy of my best selling book Wicked Cool Shell Scripts, but if that's not in your budget, there's another possibility to explore.
Shell Script ProgrammingExtracting the correct column with "ps" and "awk"
A reader writes:
Every *nix implementation is different. But I'm seeing some some shared behavior between HPUX and Solaris with script #52 Killing Processes by Name. The problem is that the script is trying to kill the "tty" name, instead of the pid. Shell Script ProgrammingExtracting Directory Names within a Shell Script
A reader writes:
First, thanks for writing Wicked Cool Shell Scripts. I've found them quite useful and I've learned many things from those scripts. I just have a question and I was wondering if you could point me in the right direction. Shell Script ProgrammingAnother approach to working with "awk"
A reader writes in with the following note:
I've just picked up your book Wicked Cool Shell Scripts, and there are a lot of nifty things in it. I too have accumulated a lot of things generally in small scripts or more frequently in bourne/bash functions. I was particularly tickled to see a lot of very similar code, one such that jumped out at me was your gmk function in one script (I called mine kmg). Shell Script ProgrammingPermission to reuse the Wicked Cool scripts
I have received a number of queries from people in the Unix/Linux community asking for the details of ownership and copyright for the scripts included in my best-selling Wicked Cool Shell Scripts. When I first started programming and distributing my works online (in the early 1980's) no-one really worried about any of that and if the original author's name stayed intact, we'd think that was a wonderful thing.
Shell Script ProgrammingHow do I do just incremental backups?
A reader writes:
"My question concerns backup.sh (script #56 in the book Wicked Cool Shell Scripts). I am a little confused how to set up my directory list file INITIALLY to use for the backup script to work. Do you have to do a -f (full backup) first, then I'm free to incrementally backup as desired? Even then I'm only interested in backing some key directories not my whole home space...." Shell Script ProgrammingGetting the "adduser" script to work on Linux
A reader writes:
" Hi, I'm a very beginner at shell scripting and unix/linux. I have your book (Wicked Cool Shell Scripts) and it is really great. So far I've done two or three, Inpath is the one i use most. I'm going make a user for an ftp account so my friends can upload/download songs and other files. I decided to use your adduser script for the job but when i run the script i get an erorr like - /etc/passwd : permission denied. How do i give the script permission to write to /etc/passwd? Sorry if this is an obvious question but i couldn't find an answer. I used chmod 755 and ran it as root. By the way, i really like the site and book cover, i wish all linux/programming manuals had really cool covers." Shell Script ProgrammingAccuweather changed, and now the 'weather' script is broken!
A reader writes in to report that Accuweather has changed their Web page layout and the shell script from Wicked Cool Shell Scripts that returns the weather forecast (script #63, weather.sh), is broken.
Shell Script ProgrammingNifty shell script of the day: calculating standard deviation
If you find yourself working on the command line and need to whip out a quick statistical analysis or two, you'll be glad to know that Wicked Cool Shell Scripts fan Josh Kotecha has sent in a very nice little shell script that does just that using the scriptbc script included in the book.
Shell Script ProgrammingSneaky ls flags and bestcompress
Another hiccup in a script included in Wicked Cool Shell Scripts, one that's a subtle problem because it sometimes occurs because of a user-set LS_OPTIONS flag. Script #37, bestcompress, has the following sequence:
smallest="$(ls -l "$name" $Zout $gzout $bzout | \ Shell Script ProgrammingPermission checks in shell script
A reader of my new book Wicked Cool Shell Scripts pointed out that the capability of testing a file permission with find using the '+' notation is GNU-specific.
HTML and CSSCan you prevent people from linking to the media on your Web site?
A friend writes:
I'm finding that some number of people are hosting my Janet Jackson "movie" by simply linking it in from their sites, meaning *I* get to pay for the bandwidth. Is there some way to prevent this? Shell Script ProgrammingFixing Mac OS X's "periodic" command
I've been discussing the key tasks that a Mac OS X user has to run to ensure that their system stays healthy and in tip-top shape, and one set that we've all agreed upon are the daily, weekly and monthly cron jobs. You can figure out when they're run with a simple grep command.
|
![]()
Search
Find just the answers you seek from among our 2000+ articles by using our Lijit search engine.
Help!
Subscribe to
Articles and ReviewsAsk Dave Taylor! Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Industry News and Trade Shows Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries on Ask Dave Taylor!
Join the List!
Book Links
Creating Cool Web Sites
Wicked Cool Shell Scripts Learning Unix for Mac OS X Panther Solaris 9 for Dummies Teach Yourself Unix System Administration in 24 Hours Teach Yourself Unix in 24 Hours Creating Cool HTML 4 Web Pages Dynamic HTML Weekend Crash Course
Sponsor Adverts
|