Welcome to the TechSpot OpenBoards. Please read the FAQ if you have any questions. Login to participate.
|
|||||||
Command the power of the command line
![]() |
| Thread Tools |
|
#1
|
||||
|
||||
|
Command the power of the command line
I came across this (hopefully) helpful article about command line basics.
Speaking UNIX: Command the power of the command line Learn the basics of the UNIX shell and discover how you can use the command line to combine a finite set of UNIX utilities into data transforms. |
|
#2
|
|||
|
|||
|
Good stuff, but then there's something wrong with his verbatim copy of a directory... You should add the p option to the tar extraction command, in order to preserve file attributes (ctime, mtime, atime, owner, group) - ie, tar xpvf and not tar xvf.
I use this regularly in order to make verbatim copies of a directory: (cd /path/to/src/dir && tar cf - .)|(cd /path/to/dst/dir && tar xpvf -) |
|
|
|
#3
|
|||
|
|||
|
Here's a good example of the command line in use. At my job, the internal DNS zone files only mapped addresses up to 191.168.1.81, thus unresolving all addresses from 82 to 254. With this simple command, I updated both the zone file and reverse zone file:
for i in `seq 82 254`; do echo -e "dev$i\t\tIN A 192.168.1.$i" >>local.zone; echo -e "192.168.1.$i\t\tIN PTR dev$i." >>local.reverse.zone; done And voilà, job done - well, after hand editing both files and changing the serial and then typing service named reload. |
|
#4
|
|||
|
|||
|
Another good one
![]() My girlfriend programs Java, and she got herself in her head to write a program to solve Sudoku grids (and it works!). However, she needed grids... Well, she found an URL giving different grids each time it was invoked, and gave it to me. I had to take the case with values in them and output for each grid the correct instructions to set the grid. To make matters more complex yet, the grids were 16x16, and numbers 10 to 16 were printed A, B, ..., G. She wanted the numbers. Complex task? No, a quick look at the generated HTML, and a one liner: for i in `seq 30`; do htmlcode=orig.$i; gridfile=grid$i.java; wget -O $htmlcode -nv http://the.url/which/I/dont/remember; echo "// Grid $i" >$gridfile; perl -ne '($x, $y, $val) = /name="sudoku\[(\d+)\]\[(\d+)\]" value="(.)"/ or next; $val =~ /\D/ and $val = 10 + (ord($val) - ord("A")); print "grid.set($x, $y, $val);\n"' <$htmlcode >$gridfile; rm $htmlcode -f;done OK, this one is a little complex, but I did type it in one line only The time to build it properly, double check it, generate the thirty grids: 20 minutes, the vast majority of which has been spent downloading the grids... |
![]() |
| Thread Tools | |
|
| Similar Topics | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Computer will not boot up, Power supply shows green led light on mother board | chrisco | CPUs, Chipsets and Mobos | 3 | 11-28-2007 12:06 PM |
| Help please! PC power up problem! | Diablo23 | CPUs, Chipsets and Mobos | 10 | 06-14-2006 05:54 AM |
| World's Tiniest Power Supply Enables Design of Small, Quiet PCs and Smart Appliances | Julio | News & Interesting links | 2 | 01-27-2006 03:58 AM |
| New Turbo-Cool 1 Kilowatt PC Power Supply | Julio | News & Interesting links | 3 | 09-09-2005 01:50 AM |
| Toshiba G25-AV513, 120W Power Supply, Airline Power limitations | kcrouse96h | Other Hardware | 0 | 07-30-2005 12:30 PM |
All times are GMT -4. The time now is 12:35 PM.




