BASH -- and ksh, and sh -- care about spaces in a few other places as well.
This is wrong:
This is okay:
This is also okay:
[[ ]] are extended versions of [ ]. They support the same things [ ] do and more besides. Look for test operators in the advanced bash scripting guide to see what flags you can do, like if [ -d directory ] # Is 'directory' a directory?if [ -z "str" ] # Is "str" a blank string? (no, that's "" )
Also, you can do things like this to process files efficiently without backticks:
you can substitute [ ] style tests for the 'read' statement there. In fact you can put [ ] statements anywhere you'd put a command, and vice versa. [ actually used to be a command, as in, there was actually a /bin/[ file which ran when you did if [ -d directory ] Your system probably still has /bin/[ or something like that somewhere for compatibility, even though it's probably not using it anymore.
This means you can use if to detect whether a command succeeded or not without counting lines or checking its backticks output or anything like that. You can just do
! also works where you might expect it:
---------- Post updated at 01:26 PM ---------- Previous update was at 01:17 PM ----------
Another unique feature the bourne shell has and csh simply cannot do is this:
You can redirect or pipe the output of entire code blocks, not just individual shell statements.
Hi everyone. I guess I am the new guy, and also new to Unix. I purchased a box of computer supplies at an auction, and found an unopened box of Compaq Smartstart. So here is what I have... Smartstart 2.5, Netware, Windows NT, OS2 & Lan Server, SCO Open Server release, SCO Unixware 2, Oracle 7 for... (3 Replies)
... before you role your eyes, I picked up my first Unix book 3 days ago! As such, I have a few quick questions that I'm sure are super easy for everyone out there but me! Forgive me if the terminology I use is wrong ...
I'm accessing a remote Unix server, I can make my way around directories... (2 Replies)
1. I have never used or dealt with unix, linux, or any variation thereof, and want to. My biggest problem is that all the versions I've looked at want you to install from a CD or DVD, but I'm wanting to put it onto an Asus eeepc, which has no such drive. How would I go about installing on it? ... (4 Replies)
This is the Test_Data.snp file: MEGAUPLOAD - The leading online storage and file delivery service
1. The problem statement, all variables and given/known data:
Problem Set:
Before you get started working with these challenges, be aware that the first challenge is reformatting the test data... (7 Replies)
hy guys,
I have perl script provided to me but i need to convert it into shell .Can you help me in this using sed shell command.
cat /etc/passwd |perl -ne '/^(\w+):\w+: (\w+)/ and print "$1, $2\n";' (1 Reply)
Hello,
For some time I have intellistation 9111-285 and I installed AIX 6.1 on it. As a complete beginner I have 2 questions in general about AIX and two specific:
1. is the SMS (system management services) part of AIX? As I noticed when I had Yellowdog Linux installed they weren't available?... (2 Replies)
Hi !!
I'm rather new both to the UNIX and scripting worlds, and I'm learning the ropes of scripting. Having said this, please excuse me if you notice certain basic errors.
I'm working on a script that implements .jar and .war files for a WAS environment and I need to perform certain... (4 Replies)
hi all, i am very new to linux and am trying to create a basic script.
I would like the script to copy files from one directory into another, (e.g Script ~/my-documents/fileone ~/my-documents/filetwo)
Once all files have been copied, i'd like another script to run automatically and rename... (12 Replies)