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 < $(echo $string | wc –c) test `wc –l filename` -ge 10000 If I try this with this code: #!/bin/sh/ value=3;string="my horse Horace" test $value < $(echo $string | wc -c) 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 < $(echo $string | wc -c) is actually trying to do? I don’t quite understand the $(…) part … and is the < performing a ‘redirection for input’ or is it meant to be ‘less than’? How do I change my PS1 command prompt in Bash?I have read about 15 chapters of your book (Teach Yourself UNIX in 24 Hours) so far. We are using vi. On the PS1 command, how do I see what is in it so I can add to it and not change what is already there? We are using bash. What I see now is: ctdaywbsdv:/u/gwilki$ When I enter ‘echo $PS1’ I get: $ \[\e[0m\] How do I keep the above and add the histcmd option? What does the \e and 0m\ mean? What do the [] the square brackets mean? I can’t find a man page for PS1. How do I find the rest of the options for this PS1? How do I get "vi" shell edit mode in Mac OS X Terminal?I just finished Learning Unix for Mac OS X Tiger, and think it is an excellent little resource. I'm recently out of school, a school where we weren't taught anything about Unix, just enough to get by. I started work with the data converter team at Agilent labs, and have been able to glean quite a bit off of them (considering many of them were either directly or indirectly responsible for writing many of them commands in common use today). Thus, I'm often embarrassed to ask them questions about exactly some of the stuff you cover in the book. 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? :-) Why do my FTP transfers all freeze up?I've been trying to copy some files off an FTP archive, but every time I go to do the transfer, it says "Entering Extended Passive Mode" and never gets any further. My conclusion: this passive mode thing is a bust. How can I transfer the files without using passive mode? I'm using ftp from within a Terminal on my Mac, by the way. How can my server be DNS spoofed?Help! For some reason when I try to use "ssh" to connect to my server from my Mac, it fails and is saying that I might be a victim of a "DNS Spoof"? What's going on, and how do I fix the problem? 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? How do I mask a password from "ps"?i need to run a process, PB, and keep it running, for avoiding problems i run it as background providing the user, and password, for connecting to oracle, this with the command: PB -u myuser -p my password & but by using 'ps -ef | grep PB' anyone can see the password. There is another way to run the process, run it in foregroung: PB -u myuser and it prompts for the password I would like to run the process in background, but avoiding the password to be shown with any 'ps'? My background jobs in Linux have become invisible?Last night i started downloading all of Fedora core via rsync. It was getting late, so I put it in the background and logged out. i just logged in this morning, and wanted to see where it was at, so I typed "jobs", but surprise, it isn't there. I know it's still running, because the lights on my hub are still blinking, it shows up in "top", and i can see (du -bs fedora/) that the folder is still growing. How do i get the output back on my terminal? Sony PSP Connected to Linux Systems?I want to transfer music and movies to my Sony PSP, on my computer I'm using Suse Linux 9.2. What kind of program or software can I use? The problem is that my computer can't find the Sony PSP when I plug it in the USB port. How do I set the shell prompt in Mac OS X Terminal?I'm new to Mac, last Apple I owned was a IIe in the 80's. This question is related to your book Learning Unix for Mac OS X Tiger book, page 41 "Changing the Command Prompt. In this section you give the following command for changing the prompt: PS1= "? " I typed this, but got the following response from the terminal window: -bash: ? : command not found What am I doing wrong? What does "cat -" do on the Unix command line?Hello I would like to know the what exactly does cat - mean in Unix? I was recently reading through an article that mentioned this command and couldn't understand what it did. Latest edition of "Teach Yourself Unix in 24 Hours"?I received this lovely email message from a reader this morning: "Just wanted to thank you for "Teach Yourself Unix in a Week." I read the whole thing cover to cover back in '94, when I was sleeping on a cot at work (!). It got me started in the world of Unix and has provided me employment ever since. My buddy Nick and I owe both you and Kamran Hussein a night of beers for kicking off our sys admin careers." Can my PATH include directory names with spaces?
Dave, I would like to use an environmental variable to change directories and included files into vim on Mac OS Tiger. I've found that this works:
export pm="/volumes/Macintosh HD/Documents/pmwiki" for shell commands, but then I have to use something like: cd "$pm" Is there a better way which doesn't require the double quotes? Also, is there some interaction with the PATH variable? How can I hide passwords in a shell script?Dave, we have to do sudo in a shell/perl scripts for certain commands. As you know sudo needs password to be supplied. sudo has -S option for stdin. For example: echo $pw | sudo -S command Assume, somehow, we figure out the password and pass it in for the above echo. But, the buggest concern is, if someone does a "ps", one will be able to see the password. The above example is part of a shell script and what we need to know is how do we hide the password? How do I delete all occurances of a file in Linux?How can I delete one file from every place on my disk using Linux? In Windows' I'd open up a command window and use the command del archive.txt /s but what's the Linux equivalent? Where can I find docs for Sony DDS hardware?Hi Mr.Dave, I am Max from Italy and I am a technician. At the moment I am searching for tutorials or service manuals about DDS2-3 and AIT1-2-3 like the SONY SDT-7000, SDT-9000, SDT-10000 and SONY SDX-300C, SDX-400C, SDX-500C but with no results!! I strongly need these documentations, because i must repair these DAT units. Helicoidal scan technology is used in these devices and our clients use those under SCO OPEN SERVER 5.0.4. I have already requested this material from SONY, but their answer has been negative. Porting C programs from Windows to Unix?Dave, I read your books Teach Yourself Unix in 24 Hours and Wicked Cool Shell Scripts and since then I can't imagine working again on a system like windows! My problem is that I've started to make my C files Unix-compatible but I can't find a command for C in Windows that does the same thing as system("cmd") for Unix. Any suggestions? Configuring Squid as a Linux Proxy Server?Dave, I am running an Internet Café in which I have about 10 workstations and one server. Now I am planning to configure a proxy server on LINUX for my cafe to improve performance in browsing. For this I have installed Complete REDHAT 9.0 in a machine equiped with 1.3G RAM, 80GB HDD, 1GHz MP, Intel P4, plus 2 NICs (Real Tech). But I have no idea about how to configure PROXY on it. Kindly let me know about any links or tutorial which can help me in a jumpstart. I do not want to mess with linux deeper. I just want to sonfigure PROXY and that is it. How can I quickly create millions of tiny files in Linux?Dave, I have searched the web over and can't seem to find an appropriate answer to this question. I have a need for a script that will create millions of 1-5Kbyte files in a linux filesystem for testing purposes. I have to do this on a regular basis and it would be really cool to have it scripted. I am not sure what the quickest way to do this would be? How do I flatten a directory structure in Unix?Dave, how can I flatten a directory structure? I've got a directory "foo", with many more sub-directories and files within. I want to take all the files from all levels beneath foo and put them in foo itself. I've tried this: find . *.mp3 -print0 | xargs -0 mv . but I get an error on the mv command that I can't figure out. Help! Where can I find the 'rev' utility for Solaris?Dave, I am a Sun Solaris sysadmin and really liked your book Wicked Cool Shell Scripts. However, I don't seem to find the "rev" utility on any of my Sun servers running Solaris 2.6, 7, 8, and even 9. I couldn't find it on the sunfreeware.com site either. Could you tell me where I can find it?
How do I selectively copy files from a directory structure?Dave, I want to copy a directory tree BUT I want to specify the root of the operation and the destination directory and then specify name/type patterns a la find. The result I want is the root at the destination and then only the directories which have files that match the pattern and the files themselves. Does that make sense? Why do the fonts in Firefox Linux look so terrible?Dave, Why is it that, "out of the box", the Firefox browser looks great (font wise) when run on a Windows OS but looks terrible (almost too small and unreadable) on any Linux OS I have tried it on. It is probably the number one killer reason for me not switching to Linux. How do I list files that don't match a pattern?Dave, I have a straightforward Linux question that's got me stumped. I have a directory with lots of files that include an underscore, but I want to produce a listing of files that don't have the underscore, not those that do have it. I can get it with a combination of ls, grep -v and such, but it's painful and convoluted. Is there a simpler solution? How do I set up Mail Filters in Ximian Evolution on Linux?
I've been migrating to Ximian Evolution on my Linux box and I love it, but I haven't been able to figure out how to set up all the mailing list rules I want to add to the program. Can you help me figure out how to set up a mailing list rule?
How do I search lots of files at once?
Dave, I need to conduct a number of searches through more than 2500 text files. Each search is for a different specific text string. The text files are on my Mac hard drive (Mac OS X 10.3.7) and are arranged into folders within folders within folders. I want the result in a new text file. I think I should be able to do this using some sort of grep or script but cannot figure out how to do it. Please help.
Can you explain exactly how umask works in Unix and Linux?
Dave, I know you can't solve trivial questions for everyone, but if you could have someone help me with the umask command and the content on pp. 107-109 of your book Teach Yourself Unix is 24 Hours, I'd appreciate it. I've taken two hours to try to figure out how in the world umask 277 produces a read-only file. It seems to me it would be write only. Can you shed some light on this, please?
How do I keep my Safari bookmarks in sync?
Dave, I have a number of different computers running Mac OS X, and would like to keep my Safari bookmarks in sync. I don't necessarily need to to have these bookmarks accessible within other Web browsers (though it'd be a bonus if Firefox saw them too) but if I designate one as my master bookmark file, is there any way to have my other Safari browsers stay synchronized?
Does -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! What'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:
How do I add custom SpamAssassin rules for content filtering?
Dave, using SpamAssassin, how do I proceed with content filtering? I want to block 15 words that can appear in the email being sent to me. I already have SpamAssassin set up on my Linux system, I just need to figure out how to configure the rules file properly!
How do I skip certain directories in "du" output?
On a mailing list I'm on, someone asked an interesting question about the du command: "I want to figure out how much disk space I'm using in different directories, but I don't know how to exclude certain directories from the output. Anyone have a suggestion?"
Does Lynx request images when viewing a Web site?
A reader writes to me: "I work with HumaniNet, an organization that assists humanitarian field teams with their communications needs, mostly over satellite. Bandwidth is typically very expensive, in the dollars per minute range. Am I correct to assume that Lynx doesn't even request images or other forms of 'rich content' like Flash, and would therefore save dramatically on bandwidth costs? In other words, Lynx doesn't download anything beyond (x)html, right?"
What capabilities does the Lynx text-only Web browser offer?
A reader writes in to me, asking whether I think that the Lynx web browser, a command-line screen-oriented alternative to the big, splashy graphical web browsers like Firefox, Mozilla, Safari and Internet Explorer, has any relevance in the modern world of technology and broadband. It's a fair question, and in fact I just published an article in SysAdmin Magazine on this subject.
What capabilities does the "cat" command have?
A reader writes:
I had taken an intro course to UNIX a few years ago, but have found your book Teach Yourself Unix in 24 Hours MUCH more comprehensive and user-aware! Answers to the questions in Teach Yourself Unix in 24 Hours?
A reader writes:
I've just bought your Teach Yourself Unix in 24 hours, and I have to tell you that I love the book. I always answer the questions at the end of each chapter without knowing whether I get it right or wrong. Do you provide solutions to those answer questions? How do Unix / Linux "hard links" work?
A reader writes:
So, I'm partway through your book, and I want to check on hard links. When you say it creates another door to the same body of data, is that literally true? For example, if all I have in my ./Documents directory is 001.doc (size 512K), and I hard link as hardlink.doc then run ls, do I see A or B? Question about regular expressions
A reader of Learning Unix for Mac OS X Panther writes in to ask for an explanation of the regular expression shown in this command:
du -s * .[^.]* Chopping off the last field of each line?
I'm working on the Web site for Creating Cool Web Sites and just realized that the little Unix trick I used while editing a file is actually a beautiful example of why so many people love Unix so much, so I thought I'd share it. The problem: a file where lines have 1-10 words + a last field value (in this case, a page number) that I don't want. The challenge is to figure out how to easily remove that last field, when there are a variable number of fields on the line.
How do I tweak my PATH?
A reader writes:
"I've got a few of your books and today picked up Wicked Cool Shell Scripts, which I'm very much looking forward to working with. Unix environment for Windows?
A reader writes:
"At the end of TYU24, you mention MKS as a Windows-based shell. I checked their website as an avenue of learning Unix/Linux without resorting to dual-boots, or multiple systems (I'm a little short on space to accomidate another tower, and short on cash to build a new micro). While they do offer evaluation versions, and educational discounts, they are still a little steep on the price range. Is there another package that may follow GPL (GNU Public License) or maybe a more cost effective package for home use?" Teach Yourself Unix in 24 Hours |
Search
Find just the answers you seek from among our 1600+ articles by using our Lijit search engine.
Help!
Subscribe to
Articles, Reviews and Cool StuffAsk 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, XHTML & CSS Mac OS X Help MySpace Help and Online Networks Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Basics Unix and Linux System Administration 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
|