sc: the Venerable Spreadsheet Calculator
Boy, there sure is a lot of software for Linux—a lot of software! Why, if you want a browser, you can choose between Firefox, Opera, Chrome, Galeon, Surf and many others. And, on the command line, wget, curl, Lynx, ELinks and more are available. For e-mail, options include Evolution, KMail, Balsa, and xmh; or on the command line, you can use mutt (my favorite), sup, pine, mh and countless more. Calendaring choices include the GNOME calendar, KDE calendar, xcal and Evolution; or, in a terminal, you can use the very powerful Remind or ccal, not to mention command-line interfaces to the Google calendar. And for spreadsheets, you've got OpenOffice.org's OOCalc, Gnumeric, KSpread and Xspread; or, in a terminal, you've got perhaps the best spreadsheet of all, sc, especially if you're a vi fan.
I've been using sc for years, mostly for budgeting and project planning. The earliest version I've found was posted to comp.sources.unix on August 18, 1987, by Robert Bond (see Resources), but that was already version 4.1. The post said it was previously known as vc, and that the original version was written by James Gosling (of Java language fame) in September 1982. Although documentation for sc can be hard to find, it does come with a decent man page and a neat tutorial, which you can load right into sc. It also uses the same file format as Xspread, so existing documentation on formulas in Xspread (which is more plentiful than for sc) also can be helpful.
If you use Debian or Ubuntu, just type sudo apt-get install sc. If your distribution doesn't have an sc package, see Resources for a link to the source. Start the program by typing sc in a terminal, and you'll see a screen that looks something like Listing 1. Because it's curses-based, you can run it over slow links, as well as inside screen, so that you can detach and re-attach from another terminal. There is a pretty detailed man page, which (in the Ubuntu package) points out that you can start up sc with a tutorial by doing this:
Actually, that isn't quite right. In Ubuntu, first you need to uncompress the tutorial:
sudo gunzip /usr/share/doc/sc/tutorial.sc.gz
Then start it.
Listing 1. Starting Up sc
sc 7.16: Type '?' for help. A B C D E 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
If you prefer to get started immediately with some real data, here are some useful commands. Like vi, sc starts in a command mode. The vi movement keys, hjkl, move left, down, up and right among cells, as you would expect. To jump straight to cell D3, press gD3. You can begin entering a numeric value or formula using =. To interrupt a command gracefully, press Ctrl-G. See the Basic sc Usage in Command Mode sidebar for more simple commands.
Basic sc Usage in Command Mode
hjkl — vi keys motion (or cursor keys).
gB13 — go to cell B13.
ir, ic — insert row, insert column.
ma (mb, mc and so on) — “mark” cell as a (or b, or c and so on).
ca (cb, cc and so on) — copy contents previously marked with ma.
Ctrl-f, Ctrl-b — page up or down (also pgup, pgdown).
dr, yr, pr — delete row, yank row, put row.
dc, yc, pc — delete column, yank, put column.
dd, yd, pd — delete, yank, put a cell.
= — enter a numeric value (25 or F13-D14) or formula (@sum(A2:A145)).
< — insert left-justified text.
\ — insert centered text.
> — insert right-justified text.
x — remove cell.
W<filename.asc> — write plain-text file.
P<filename.sc> — write an .sc file.
G<filename.sc> — read (“get”) an .sc file.
Zr, Zc — zap (hide) row or column.
sr, sc — show row or column.
@ — force re-calculation.
e — edit a numeric value.
E — edit a string value.
To me, the three most important things about working with spreadsheets are the ease of adding new data, moving data and defining simple formulas that are re-calculated automatically. sc shines as far as the first two requirements with its vi-like command mode. It also does quite well with formulas. Check the on-line help for a sizable list of formulas, but the most common function in my experience is simple addition. This is no different in sc from any other spreadsheet.
To put the sum of the values in A3 through A10 into A12, go to cell A12, and type =@sum(A2:A10). To edit the formula, press e for edit, and you will be in command mode in the top line, editing the formula. Edit as you would in vi, and press Return to save the edited formula.
If you want to insert five more rows before row 5, go to cell A5, and type 5ir, which means “do 5 times: insert a row”. The formula (now in A17) will be updated automatically to read @sum(A2:A15). Now you can copy that formula into cell B17 by going to A17, typing ma, then going to B17 and typing ca. The formula will be updated automatically to read @sum(B2:B15).
If you want to highlight some specific data in the spreadsheet without actually having to delete rows, you can hide the uninteresting ones. This is called zapping in sc, and you do it by pressing Z followed by either r for row or c for column. (If you follow it with a Z instead, sc will assume you meant save and exit as ZZ does in vi.) You can un-hide by using S for show, followed again by r or c. Again, you can type 30Zr to zap 30 rows.
I've already mentioned the tutorial and detailed man page, but sc also has on-line help, which you can see by pressing ?. There, you will find settings you can toggle, ways to move the cursor, lists of financial functions and so on.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- SUSE LLC's SUSE Manager
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- My +1 Sword of Productivity
- Managing Linux Using Puppet
- Non-Linux FOSS: Caffeine!
- Doing for User Space What We Did for Kernel Space
- SuperTuxKart 0.9.2 Released
- Parsing an RSS News Feed with a Bash Script
- Google's SwiftShader Released
- Rogue Wave Software's Zend Server
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide