shell script programming -- Industry guru Dave Taylor answers questions about a wide variety of technical topics, including HTML, online advertising, Cascading Style Sheets, Web design, Unix, Linux, search engine optimization, Mac OS X, shell script programming and Microsoft Windows.

"shell script programming" Help and Information



How 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?...

Continue reading about How can I keep a compressed Linux archive up to date?

How 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?...

Continue reading about How can I count letters in a text file?

How 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...

Continue reading about How can my shell script test server status?

How 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...

Continue reading about How do I read prior lines in a text file?

Can 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?...

Continue reading about Can I automate craigslist searches?

How can I read a password without echoing it in C?

I'm trying to figure out how to disable the echo flag in C. I want to do this because I am coding a C program that must ask for a users password, so I would like to disable Echo, let the user enter his password, then re-enable Echo....

Continue reading about How can I read a password without echoing it in C?

What does the $( ) notation mean in a Bash script?

On page 329 (Hour 16) of your book Teach Yourself Unix in 24 Hours is the example: value=3 ; string="my horse Horace"test $value test `wc –l filename` -ge 10000 If I try this with this code: #!/bin/sh/value=3;string="my horse Horace"test $value test `wc -l ched4` -ge 10000 I get:- syntax error at line 3: `(' unexpected Are you able to quickly explain what the line test $value...

Continue reading about What does the $( ) notation mean in a Bash script?

How 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....

Continue reading about How many Friday the 13ths are there in a given year?

How 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?...

Continue reading about How do I turn a command line into a shell script?

Can 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?...

Continue reading about Can I create an Apache image directory browser script?

How 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?...

Continue reading about How can I time portions of a Linux shell script?

Do 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? :-)...

Continue reading about Do most music CDs have 12 tracks?

Script 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....

Continue reading about Script to rename thousands of files and directories?

How 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   0000000016   0000000012   0000000008 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?...

Continue reading about How do I strip leading zeroes for math in a shell script?

How 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: -b username yyyymm so if i say 200504. i will have to back up all the files in that specific month to my home directory...

Continue reading about How do I identify files changed during a specific month?

String 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!...

Continue reading about String comparisons don't work in shell scripts?

How 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?...

Continue reading about How can I run an app if another app is running?


Advanced Search :: Ask Dave Taylor!


Match case   Search using regular expressions
Search: Entries Comments Both
Sort By:
Sort Order:
Search entries from:
Maximum results shown:


Need Help? Ask Dave Taylor!
Search