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


Printing multiple files

I have 25 .txt files that I would like to print. They are named 1.txt, 2.txt and so on. How can I do this?



Title Last Comment
Understanding Perl's map function  
- Understanding Perl's underappreciated map function - basic usage and examples -

Running a command at a particular time  
- I have a cron job that runs every hour. Within that script I need to test for specific times. -

How can I find out when our anniversary falls on a Saturday?  
- How can I find out when our anniversary falls on a Saturday? I thought it would be easy, but it doesn't seem to be? -

I need to send a kill -1 to a process  
- I need to send a kill -1 to a process but I can not get the pid from a file as it's location is different on some systems -

Shell script cannot test for the existence of files  
- My shell script needs to move certain files to another location. How do I test that the files exist? -

Why does this variable become blank?  
- Why does this variable become blank? It's obviously set in the first part, but it goes away. -

Managing iptables drop lists  
- After blocking large numbers of sites accidentally, cleaning them out is easier with this script -

Take Control of the Mac Command Line with Terminal  
- 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. -

Restrict script to console use  
- How to restrict a shell script to prevent use by ssh or to only be used at the console. -

Removing empty directories  
- Follow along as we segue and digress, dive deep and reverse ourselves all while trying to avoid the pedantic spoilers who would surely ruin our fun emptying our directories. -

Perl directory listing  
- 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. -

Run a script every other day but not on weekends  
- While this became much easier with Vixie cron, there are still circumstances that need some extra help in the script. -

Printing multiple files  
- I have 25 .txt files that I would like to print. They are named 1.txt, 2.txt and so on. How can I do this? -

Shebang - What's the point of #!/bin/bash?  
- Shebang, hashbang, pling - whatever you call it, what's the point? What does it do? Do you need it in shell scripts or not? -

Determine Unix/Linux version and cpu's  
- Usually some variant of uname, often 'uname -a', but all sorts of other possibilies; it depends on the Unix and in some cases even the specific version. -

Passing shell environment variables  
- Is there anyway for a child process to set an environment variable visible to its parent? -

View large files without more or less  
- I have a rescue disk that doesn't include "more" or "less" - how can I examine large files? -

Losing white space IFS   2013/07/22 TonyLawrence
- The shell doesn't really destroy anything; it's just doing what it should - ignoring repeated white space. -

How do I find out what IP address a user logged in from?   2013/11/13 TonyLawrence
- Obtaining a client IP address on Linux/Unix is not always direct or easy. You may have to dig it out of shell command output. -

 
 











 
 
Script to block DOS attacks   2013/06/03 TonyLawrence
- People steal content. If you run a website, you almost certainly know that; here is a simple script to block annoying abusers and possibly stop a little theft, too. -

Learning Spanish with a little help from Perl   2013/04/16 TonyLawrence
- A little Perl script helps me refresh my Spanish knowledge. -

Early reminders for first Monday of month events  
- I kept forgetting to send our club meeting notices to the newsletter. Google Calendar couldn't help me, so I wrote this script. -

Here files (shell scripting)   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/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)  
- 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  
- 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. -

Higher resolution timers in the shell  
- 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. -

Perl Date::Manip for date validation  
- Validating dates can be tricky, but Date::Manip makes it easy (at the cost of a little speed). -

KCMENU (Kevin Clark's menu generator) in Perl  
- Translate old kcmenu files to Perl scripts - a simple Perl based menu script. -

Is sed dead?  
- 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/20 TonyLawrence
- ls might have more flags than any other Unix command and operating system variance is wide. The lowly ls command has a lot of flags, perhaps more than any other Unix command. -

Finding Yesterday's Date   2014/02/05 TonyLawrence
- How to find yesterday's date on Linux, Mac and any other Unix. -

Yesterday's Date   2010/04/01 TonyLawrence
- Recently I was asked how to write a script that would automate the task of copying a log file to another directory -

What does a leading colon (:) mean in a script?  
- Bash and sh use colons as a separator ($PATH, for example), as a modifier (${n:="foo"}) and as a null operator ("while :"). -

Using System V interface scripts with CUPS printing   2013/11/22 RickHoyle
- But what if I wanted to add an automatic form feed to the end of that, or do some other special processing? -

Using color in shell scripts (Linux, Mac OS X)   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. -

Awk vs. Perl   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. -

Shell script used time  
- What that does is show you the last time a file was used which can be very helpful in tracing whether or not something happened when you expected it to -

Breaking out of a script  
- Sometimes you just want to bail out of a script when something happens. Let's say we're testing the output of some "chk" command and want to exit if it says "No". That's easy: we just add "chk | grep -q "No" && exit 0" to our script. If that "chk" spits out "No", our script is done right then and there - no more of it will be executed. -

The Linux of our Understanding  
- How much do we really grok? I decided to read the complete Bash man page and see where I was left slack jawed. -

Bash Brace Expansion  
- Simple Bash Brace Expansion. The new tricks Bash has picked up in 3.0 are exciting and useful, but simple brace expansion has been available for some time now, and yet we seldom see it used. I suppose that's because the need doesn't come up too often. -

Power failure changes my habits  
- I need to be more careful in editing scripts - a power failure catches me at exactly the wrong time! -

Using sh -c with find  
- Using sh -c imbedded in find script. I'm sure everyone reading here has used "-exec" with "find"; for example: -

Bash typecasting  
- Bash has typecasts - but only sort of and your scripts can easily break because of it. -

case conversion in bash script??  
- Now I want to convert the content of VAR ($VAR) to lowercase. How can I do in bash. -

Death of the command line  
- Is command line use dying? It's hard for me to imagine using an OS without a strong command line. Even Microsoft has recognized the with their Monad Shell. -

sed help!!  
- I want to extrac (2.x) from the string and store in a variable. How can I do that. -

Continuation Lines   2010/05/28 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 shells call other programs  
- Kernel exec vs. shell interpretation: The implication is that the shell reads the command and decides what to do. It's actually the kernel that makes a lot of the decisions. -

Copying Mac Resource Forks with Perl  
- We have the problem that if we move a Mac executable to our Linux web server, we lose the resource fork unless we use Stuffit first. -

 
 
Samepage - Redefining how people create and share information
 
 
Shell vs. Applescript - getting input  
- Of course there are things easily done with Applescript that aren't so easy with a shell script. However, the opposite is also true. Too often I see people writing complicated (and slow) Applescript for things that the shell can do very easily. -

Why use the command line?  
- This is where you can do complicated tasks with a few keystrokes, things that would keep you and your mouse busy for hours any other way -

Bash 3.00 brace expansion   2010/11/02 TonyLawrence
- With Bash 3.0, we now have brace expansion for lists. Prior to this, we sometimes used "seq", which could result in such awful things as: -

Bash in-process regular expressions   2015/02/21 TonyLawrence
- 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. -

using bash select  
- The description of select in the bash man page is enough to give anyone a headache: -

Bash aliases  
- Most shells have some provision for aliases. Aliases can assign default behavior to a command or can be used to create new commands. -

Automating jpeg conversions  
- A thread at comp.os.linux.mis recently asked how to control the GUI in order to automate the manipulation of some .jpg files with xv. Of course this can be done,but as many posters pointed out, that's simplythe wrong tool for the job -

Bash looping   2011/08/08 TonyLawrence
- There are so many different ways to create bash loops. Let's just look at a few. After the first, I'll only list the initial line: -

How does a shell script know how it was invoked?  
- 2005/06/05 How does a shell script know how it was invoked? -



More Scripting articles
















Have you tried our Tests?