Splitting Strings Natively with the Shell: Native vs Native
In my previous post on why to split strings with bash itself, I used set to split the string.
Splitting Strings Natively with the Shell: Native vs Native
In my previous post on why to split strings with bash itself, I used set to split the string.
Today I want to discuss splitting strings into tokens or “words”. I previously discussed how to do this with the IFS variable and promised a more in depth discussion. Today, I will make the case on WHY to use IFS to split strings as opposed to using a subshell combined with awk or cut.
After a long break I have some more ideas…. Will be posting them soon. For now, I leave you with a command to clear your current environment:
root@67 [~]# printenv | wc -l
26
root@67 [~]# env -i printenv | wc -l
0
This is very useful when you want to run a command ignoring any environment variables you have set. I use this command with curl nearly everyday to ignore the http_proxy environment variable I have set. Another, longer, option is:
root@67 [~]# http_proxy="" curl ....
I prefer env -i as its simpler.
nixcraft has a link on how to read a file line by line. The method is a great way to read a file, but there some trouble spots I thought I would point out.
In the script, the special variable IFS is set:
# set the Internal Field Separator to a pipe symbol
IFS='|'
The tells the read command to split “cyberciti.biz|74.86.48.99″ into “cyberciti.biz” and “74.86.48.99″ and thus fill both the domain and ip variables here:
Irvine, CA – June 23, 2009 – Cisco® today announced a new Linux powered router, the Linksys by Cisco Wireless-N Broadband Router with Storage Link (WRT160NL). The new model complements the existing Linksys by Cisco consumer router line-up and is essentially the next generation of the popular WRT54GL. The design of the product is similar to other Linksys by Cisco N-routers, but has integrated connectors for external antennae. Consumers that prefer external aerials can now enjoy the new Linksys by Cisco router design because of the integrated R-SMA antenna connectors.
Hot deals on Notebooks from Dell, Toshiba, Gateway and more. Lots of great notebook accessories too!
Pictures and video of the ZMP Linux based Robocar. I think I don't know anybody who wouldn't want one.
I'm just curious if they can make it transport my groceries from the supermarket.
Will this be the future of handheld technology? A touch screen tracking your moves without touching it, combine this with 3D technology and you have the future in your hands. It can detect the proximity of a finger at 20mm and it senses distance. A little off topic, but we see a linux device using this soon hopefully :-)
If you have no clue what the title is about:
The story is about encrypting the part of your disk where you keep personal data, keeping the key to the encryption on a flash disk (usb stick). And if you have it inserted while logging in it will automatically decrypt the disk! If not you get a normal home partition where you shouldn't keep any sensitive data.
Great tutorial.
"Anyone that carries confidential data around on their laptop has probably considered encryption at some point or other.
If your looking for some tech stuff to experiment with, this is your toy!
A mini computer, very tiny, low power, usb powered, open platform. And there's a big community.
Check it out!
The BeagleBoard is an ultra-low cost, high performance, low power OMAP3 based platform designed by BeagleBoard.org community members and sold by Digi-Key.
don't forget to vote if you find something useful!!
5 days 4 hours ago
6 days 19 hours ago
2 weeks 2 days ago
2 weeks 2 days ago
2 weeks 3 days ago
2 weeks 3 days ago
2 weeks 3 days ago
2 weeks 5 days ago
2 weeks 6 days ago
2 weeks 6 days ago