December 11th, 2010
marco
For a system Linux is important to know how to use the Shell and its commands as thirst and awk. I'll write a little introduction with examples to help you understand the potential of these commands.
Sed command
sed is a stream editor: working with the data in a serial fashion as they would read a person. Put simply you can think of sed as a way to automatically find and replace words with other. For example, This command replaces all instances of “marco” with “brown” within the text file test.txt:
sed -e 's/marco/bruni/g' prova.txt
Anyone who has used the Regular Expressions in a text editor or programming language will find easy to grasp sed.
The awk command
Awk is a little more difficult and takes longer to learn. And’ a command-oriented record that awk is the right tool to use when the data contains delimited fields that you want to manipulate.
Consider this list of names in a file persone.txt .
Marco Bruni
Mario Rossi
Mark Green
John Blacks
to extract only the name, we can use this command:
awk '{print $1}'Persone.txt Marco Mario Mark John
or we can search only for people named Mark
awk '$ 1 ~ / Marco / {print}'Persone.txt Marco Bruni Marco Verdi
Awk can do much more, and have programming skills as variables, conditionals and loops. But even a basic understanding of how to combine and extract fields will take you far. If you want to go into that I suggest you read this manual: AA Guide Sed and Awk
What do you think?
ls is one of the basic commands of UNIX, and therefore also for GNU / Linux, with it you can monitor directories, files, permits, etc.., its output is detailed and well structured, but it can also be improved.
As?
Try to Execute:
$ (printf "PERMISSIONS LINKS OWNER GROUP SIZE MONTH DAY HH:PA PROGRAM " ; ls-l | sed 1d) | column -t
Related Articles:
http://www.marcobruni.info/it/category/linux
http://www.marcobruni.info/it/category/shell
Often the photos downloaded from digital camera, have the extension. JPG, instead. jpg, to remedy the "problem", just run the following command from the shell:
find /percorso/delle/immagini -name *.JPG -exec rename “s/.JPG/.jpg/g” {} ;
We continue to explore the wonderful world of Gnu/Linux.
Command Today, does is compress the working directory on the fly, showing the progress, and moving in the desired position.
tar-cf – . | p-s $(du-sb . | awk ‘{print $1}’) | gzip > out.tgz
What happens is that tell tar to create "-c", an archive of all files in current directory "." (ricorsivamente), print the output data to stdout "-f -", Then we go to specify the size "-s" all files in current directory, for the command "pv", next step: the "-sb. | awk? (Print $ 1)?"Returns the number of bytes in the current directory, then zip all the content and send the file to the outpup "out.tgz"
Related Articles:
Linux shell: Unzip network
Linux, the best of the past 10 years according to IBM developerWorks
December 30th, 2009
marco
From today I start to publish articles on GNU/Linux which is a free Unix-type operating system and in particular shell is not the armpit
but it is a program that allows users to communicate with the system and to start other programs.
Regularly publish these tips to become a good administrator of GNU / Linux
Why not try to unpack a tarball directly from the network, without saving the locally Package?
Let's try:
Using wget enter and run this command: wget-O – http://IndirizzoWeb/a.gz | tar xz
Or Curl enter and run this command: curl http://IndirizzoWeb/a.gz | tar xz
If the archive is compressed using bzip2 "xj" as options to tar, ie tar xj.
Recent Comments