Search posterous

Search all posts and users. Type a name, type a favorite song title, whatever! See what comes up.
  

More posterous blogs











More recommended blogs »

Here are posterous posts filed under unix...

moellus says...

Filed under: unix

timocratic says...

which produces the same result. However, brace expansion becomes quite useful when the brace-enclosed list occurs immediately before, after or inside another string:

$ echo {one,two,red,blue}fish
onefish twofish redfish bluefish

$ echo fish{one,two,red,blue}
fishone fishtwo fishred fishblue

$ echo fi{one,two,red,blue}sh
fionesh fitwosh firedsh fibluesh

Notice that there are no spaces inside the brackets or between the brackets and the adjoining strings. If you include spaces, it breaks things:

$ echo {one, two, red, blue }fish
{one, two, red, blue }fish

$ echo "{one,two,red,blue} fish"
{one,two,red,blue} fish

However, you can use spaces if they're enclosed in quotes outside the braces or within an item in the comma-separated list:

$ echo {"one ","two ","red ","blue "}fish
one fish two fish red fish blue fish

$ echo {one,two,red,blue}" fish"
one fish two fish red fish blue fish

You also can nest braces, but you must use some caution here too:

$ echo {{1,2,3},1,2,3}
1 2 3 1 2 3

$ echo {{1,2,3}1,2,3}
11 21 31 2 3

Now, after all these examples, you might be thinking to yourself, “Gee, those are great parlor tricks, but why should I care about brace expansion?”

Brace expansion becomes useful when you need to make a backup of a file. This is why it's my favorite shell trick. I use it almost every day when I need to make a backup of a config file before changing it. For example, if I'm making a change to my Apache configuration, I can do the following and save some typing:

$ cp /etc/httpd/conf/httpd.conf{,.bak}

Notice that there is no character between the opening brace and the first comma. It's perfectly acceptable to do this and is useful when adding characters to an existing filename or when one argument is a substring of the other. Then, if I need to see what changes I made later in the day, I use the diff command and reverse the order of the strings inside the braces:

$ diff /etc/httpd/conf/httpd.conf{.bak,}
1050a1051
> # I added this comment earlier

Brace expansion is pretty cool when used as pseudo-globbing.

Filed under: unix

morphar says...

Microsoft was granted a patent, that basically describes the UNIX program sudo!

It's like patenting the grinding of coffee beans, before pouring hot water over them!

For those who don't know much about UNIX/Linux:

root: UNIX/Linux administrator

sudo: a small program, which purpose is to let "normal" users act as root, by "becomming" root or execute commands as root - of course root must grant you access to use the program!..

So... It seems Microsoft was granted a patent, that describes something that *NIX users has known and used for 29 years!!!!

Am I the only one, who just wants to denounce the authority of the US patents system? I mean... If somebody says to you: "you are violating our patent", I really just want to respond with: "what's that... pad-end? What is it? AND WHAT THE #@!&% ARE YOU ACTUALLY ACCUSING ME OF!?!?! VIOLATING??!?!"... And so on... you get my drift :-P

 

Read more:

Groklaw article

Wikipedia article on sudo

 

Filed under: unix

jye4258 says...

test10

Filed under: unix

Jason says...

All the cool kids are using Fish, so why can't I? BASH is so 90's. Cause it won't fracking install on my copy of Snow Leopard, dang it. I spent the greater part of this weekend trying to figure out why Fish didn't like me. Read this so you won't have to endure my pain.

port install fish

wouldn't install. ports/fish kept asking for iconv, gettext, or whatnot. 64-bit/32-bit unix apps don't play well together in Snow Leopard, and because I upgraded from Leopard and I needed to reinstall ports to deal with it. Long and painful, indeed. You, though, can do this with 60 seconds of typing:

1. Reinstall ports (via http://trac.macports.org/wiki/Migration)

a. Save the list of installed ports:

port installed > myports.txt

b. Clean any partially completed builds, and uninstall all installed ports:

sudo port clean all
watch football/do laundry/deshell next week's pistachios
sudo port -f uninstall installed

c. Browse myports.txt and install the ports that you actually want to use (as opposed to those that are only needed as dependencies) one by one, remembering to specify the appropriate variants:

sudo port install portname +variant1 +variant2 ...

2. Install fish

port install fish

3. Make it default

append "opt/local/bin/fish" to the /etc/shells file
utilize accounts.prefpane, unlock it, right click your icon, and set your shell to "opt/local/bin/fish"

4. Voila! Enjoy fish!

For a more on Fish, here's an old Ars Technica article, and a lwn.net article.

Filed under: unix

matrax says...

RT @mackozer: Technologia Grand Central Dispatch zaimplementowana w systemie FreeBSD (#apple mac linux unix): http://bit.ly/4q3cHi

Filed under: unix

sengming says...

 

 

This is probably obvious to old school Unix hackers but didn't make ANY SENSE AT ALL until I realized that:

  1. When fork gets called without a block it spawns off a child process.
  2. Which means that the if statement will get run twice, once on the parent process and the other on the child process.
  3. if fork evaluates to true in the parent process since fork returns the process ID of the child procecess.
  4. In the child process if fork goes through the else statement instead because fork always returns nil in a child process.
  5. The child process will be left hanging in a zombie state untill Process.wait gets called in the parent process.
  6. You can't write to a pipe until you close the read port and you can't read from a pipe until you close the write port.

 

Filed under: unix

white says...

Safe-rm is a safety tool intended to prevent the accidental deletion of important files by replacing /bin/rm with a wrapper, which checks the given arguments against a configurable blacklist of files and directories that should never be removed.

Well...

While I absolutely agree that the idea is really nice and would safe a lot of asses from big pain, personally, I would never use it.

You know, there are some things in this world that cannot be taught. They need either to be fully understood and burned deeply or learned by your own pain. Sometimes a lot of pain.

Whenever I'm typing rm -r I'm already nervous. Whenever I see rm -f I'm freaking scared. This is just my gut feeling, I can't do much with it and I don't need to. I had a few painful lessons in the beginning and now I'm so thankful for that.

You know what, try rm -rf / yourself. It's not just one lesson. It's a set of lessons about working as root instead of regular user, keeping regular and proper backups, thinking before act and whatever not. You'll not forget that and you wouldn't need safe-rm anymore. :)

The same with molly-guard that prevents accidental reboots. Come on, this one is really fun. Why do you need that at all? If you server reboot is painful, you're already in danger. If your services doesn't boot well, doh, go fix it. If you don't have any load balancing and fault tolerance policy, go implement one. But don't go for the hack to save your ass from not doing anything else.

P.S. Don't get offended, just my 5 cents. :) Have fun.

Filed under: unix

This is pretty coolImage by Diana Lili M via Flickr

Let me first point out that I am a recent convert to Linux. I, like many others, was a die-hard fan of Windows, which I believe is due to shear laziness (Linux requires a little love, now and then to get it to do some of the things you want it to). Anyway, last year I was having problems with my laptop -- mostly due to my ignorance of computer operating systems -- and I was getting tired of getting my computer fixed. Also, I did not want to switch from Windows XP over to Vista, because of all the negative reviews I had been hearing. So I decided to be daring and switch to Linux.

At the time, I was working in a book store so I had access to literally dozens of books on computers: operating systems, hardware configurations, databases, programming languages, et. al. Also, there were a plethora of computer nerds working there, and just about every one of them doted on Linux. So, after perusing several 10-pound books, I took a leap of faith and bought one on Fedora Core 6 (which, coincedently, had a disk with the operating system in the back).

Migrating to Fedora Core 6 6 was a challenge, to say the least (lots of configuration screens to go through). However, even though I knew not what I was doing, I managed it quite successfully. I enjoyed using the GNOME GUI for a while. Then, for reasons I don't recall, I reinstalled FC6 using KDE. I liked that GUI much better, because it had better games on it, and we all know that you can't have a computer without some kick ass games to play. And since I was to stupid to figure out how to install an application like Wine, I had to make do with whatever came with the chosen GUI. Also -- any of you readers who are familiar with Linux can testify to this -- both desktop environments have their own set of applications, most of which are native only to one interface. Therefore, being totally ignorant of my new OS, I again reinstalled the software in order to play ther other games -- see a pattern here?

Now, going back to my educated decision on which operating system to choose, I neglected to pay attention to the fact that, being open source, all Linux distros are either continually being updated, or they are only being updated for a set period of time. (Do you see where I'm going here?) Well, a few weeks ago I tried numerous times -- in vain -- to run updates. Finally, remembering an old acquaintances suggestion -- which I had previously ignored -- I downloaded Ubuntu 8.04. The reason for going with 8.04 instead of 9.04 was because it is being maintained longer.

So. After about 30 minutes of jacking with my CD drive I finally downloaded and copied Ubuntu. After reading through everything on the website, to say I was thrilled would be an understatement. But, being Mr. Murphy's favorite plaything, luck was not on my side -- I couldn't validate or install my download. Never fear, though, because I was desperate I requested a "free" CD. Now the first thing I will brag on Ubuntu about is the fact that it took about a week to get my copy (the website says 6 to 8 weeks).

Being the impatient, ADD-afflicted freak I am, I immediately turned on my laptop and popped in the disk -- installation was as easy as one, two, three. Now I can check my Twitter account every ten seconds, email and my Facebook profile every ten minutes, and watch my FriendFeed updates constantly update in the lower right-hand corner of my screen continuously.

However, all this took some tweaking to accomplish, but being so user-friendly, Ubuntu makes it easy. If I have a question about how to install a new app, or a plug-in -- which I always do -- help is only a few keystrokes away. Also, I am easily able to update at any time.

Related articles by Zemanta
Reblog this post [with Zemanta]

Filed under: UNIX