Site perso : Emmanuel Branlard
linux commands -------------------------------------------------------- du -sh FOLDER/FILE : disk utilisation, readable by human, s : include subfolders df -al : disk space * sort Sorts lines in ascending, descending and unique order * grep Searches for regular expressions in strings or files * basename Strips the path from a path string to leave just the filename * dirname Removes the file from a path string to leave just the pathname * cut Chops up a text string by characters or fields * wc Count the characters, words, or lines * [ (test) ] Predicate or conditional processor * tr 'a' 'b' Transform characters * expr Simple arithmetic processor * bc Basic Calculator * eval Evaluate variables * echo Output strings * date Create date strings * nawk Manipulate text strings * head | tail Access lines in files FORLOOPS/ FIND / XARGS and SPACECHARACTERS ----------------------------------------------------------- SHELL SCRIPTS NOTES ----------------------------------------------------------- Conditionnals tests are in bracket [ ] See man test for details, like : Expression comparison : !EX1 -a Ex2, Ex1 -o Ex2 String comp : S1 = S2, S1!=S2 Int comp : I1 -ne I2 IF : if [] || [] && [] then ... elif [] then ... else ... fi WARNING !! you need spaces around [ and = !!!!!!!!!! STANDARD IN, STANDARD OUT | : PIPE ./compile_astra 2>&1 | tee log.loG deadbbg http://www.onlinecomputerbooks.com/
awk -------------------------------------------------------- awk is a pattern scanning and processing language. By default it reads standard input and writes standard output. Usage: awk -f progfile [--] file Usage: awk 'program' file Usage: ./awkfscript -F, : field separator comma(,) -F ";" : field separator semicolumn(;) -F ";|," : field separator semicolumn or comma(;) #first 1000 lines awk 'NR<1000 {print}' radial.ini>radi #lignes paires NR % 2 == 1 { print $0 } #affiche le numero de ligne { print NR, $0 } # First three fields awk -F, 'NR>1 {print $1,$2,$3;}' tab.csv > tab2 # Not matching a pattern awk '!/Distribution/ {print $0 } ' drift.in # Cut a line every 20 fields awk -F, '{for(i=1;i<=NF; i=i+1){ if((i%20)==0 ){ printf $i";\n" }else{ printf $i";"} } printf "\n" }' p.csv >r.csv # print sum of first record awk '{ sum += $1 }; END { print sum }' file awk -F= 'NR<10 {for(i=1;i<=NF;i++){printf $i"=" }; print "" }' drift.in #printf "&NEWRUN\n Distribution='$bunchdir/$3'\n" |tee $2>/dev/null #awk 'BEGIN{IGNORECASE=1; FS=",|="}; /distribution/{for(i=1;i<NF;i=i+2){ if($i~/distribution/){}else{ print " ",$i,"=",$(i+1)} } } NR>1 && !/distribution/{print} ' $casedir/$2 > $tempBuffer #cat $tempBuffer |tee -a $2>/dev/null awk 'BEGIN{IGNORECASE=1; FS=",|="}; /distribution/{for(i=1;i<NF;i=i+2){ if($i~/distribution/){split(ARGV[2],a,"="); print a[1]=a[2;] }else{ print " ",$i,"=",$(i+1)} } } NR>1 && !/distribution/{print} ' $casedir/$2 Distribution=\'$bunchdir/$3\'> $2 #! /bin/awk BEGIN { IGNORECASE=1 FS=",|=" split(ARGV[2],a,"="); b=tolower(a[1]) } $0 ~ b {for(i=1;i<NF;i=i+2){ if($i~b){split(ARGV[2],a,"="); print " ",a[1],"=",a[2]; }else{ gsub(" ","",$i); print " ",$i,"=",$(i+1)} } } $0 !~ b {print }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LESSON 1 SUMMARY 1. The cursor is moved using either the arrow keys or the hjkl keys. h (left) j (down) k (up) l (right) 2. To start Vim from the shell prompt type: vim FILENAME <ENTER> 3. To exit Vim type: <ESC> :q! <ENTER> to trash all changes. OR type: <ESC> :wq <ENTER> to save the changes. 4. To delete the character at the cursor type: x 5. To insert or append text type: i type inserted text <ESC> insert before the cursor A type appended text <ESC> append after the line NOTE: Pressing <ESC> will place you in Normal mode or will cancel an unwanted and partially completed command. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LESSON 2 SUMMARY 1. To delete from the cursor upto the next word type: dw 2. To delete from the cursor to the end of a line type: d$ 3. To delete a whole line type: dd 4. To repeat a motion prepend it with a number: 2w 5. The format for a change command is: operator [number] motion where: operator - is what to do, such as d for delete [number] - is an optional count to repeat the motion motion - moves over the text to operator on, such as w (word), $ (to the end of line), etc. 6. To move to the start of the line use a zero: 0 7. To undo previous actions, type: u (lowercase u) To undo all the changes on a line, type: U (capital U) To undo the undo's, type: CTRL-R ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LESSON 3 SUMMARY 1. To put back text that has just been deleted, type p . This puts the deleted text AFTER the cursor (if a line was deleted it will go on the line below the cursor). 2. To replace the character under the cursor, type r and then the character you want to have there. 3. The change operator allows you to change from the cursor to where the motion takes you. eg. Type ce to change from the cursor to the end of the word, c$ to change to the end of a line. 4. The format for change is: c [number] motion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LESSON 4 SUMMARY 1. CTRL-G displays your location in the file and the file status. G moves to the end of the file. number G moves to that line number. gg moves to the first line. 2. Typing / followed by a phrase searches FORWARD for the phrase. Typing ? followed by a phrase searches BACKWARD for the phrase. After a search type n to find the next occurrence in the same direction or N to search in the opposite direction. CTRL-O takes you back to older positions, CTRL-I to newer positions. 3. Typing % while the cursor is on a (,),[,],{, or } goes to its match. 4. To substitute new for the first old in a line type :s/old/new To substitute new for all 'old's on a line type :s/old/new/g To substitute phrases between two line #'s type :#,#s/old/new/g To substitute all occurrences in the file type :%s/old/new/g To ask for confirmation each time add 'c' :%s/old/new/gc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LESSON 6 SUMMARY 1. Type o to open a line BELOW the cursor and start Insert mode. Type O to open a line ABOVE the cursor. 2. Type a to insert text AFTER the cursor. Type A to insert text after the end of the line. 3. The e command moves to the end of a word. 4. The y operator yanks (copies) text, p puts (pastes) it. 5. Typing a capital R enters Replace mode until <ESC> is pressed. 6. Typing ":set xxx" sets the option "xxx". Some options are: 'ic' 'ignorecase' ignore upper/lower case when searching 'is' 'incsearch' show partial matches for a search phrase 'hls' 'hlsearch' highlight all matching phrases You can either use the long or the short option name. 7. Prepend "no" to switch an option off: :set noic
\section{Interface graphique GTK : GTK+ en C , GTKmm en C++} http://forums.codeblocks.org/index.php?topic=3181.0 Dans Codeblocks, voir Project -> Build options Compiler options `pkg-config gtk+-2.0 --cflags` `pkg-config gtkmm-2.4 --cflags` Si glade : `pkg-config gtkmm-2.4 libglademm-2.4 --cflags` Linker option : `pkg-config gtk+-2.0 --libs` `pkg-config gtkmm-2.4 --libs` Si glade : `pkg-config gtkmm-2.4 libglademm-2.4 --libs` \section{Un makefile propre GTKmm} CC=g++ CFLAGS=-Wall -W -g `pkg-config gtkmm-2.4 libglademm-2.4 --cflags` LFLAGS=`pkg-config gtkmm-2.4 libglademm-2.4 --libs` OBJECTS=main.o application.o HEADERS=application.hpp TARGET=helloworld all: $(TARGET) $(TARGET):$(OBJECTS) $(CC) $(LFLAGS) -o $(TARGET) $(OBJECTS) %.o: %.cc $(CC) $(CFLAGS) -c $< -o $@ clean: rm -f $(OBJECTS) $(TARGET) *~ \section{heritage de gtk::window} class Fenetre : public Gtk::Window { public: Fenetre(); private: Gtk::VBox * v; Gtk::Button b1, b2; Gtk::Label * l; Glib::RefPtr xml; }; Fenetre::Fenetre() : v(0), b1("Ok"), b2("Annule"), l(0) { // on charge le fichier xml = Gnome::Glade::Xml::create("fenetre.glade"); // on récupère des pointeurs sur les éléments de l'interface xml->get_widget("vbox1", v); xml->get_widget("label1", l); // on déplace la VBox de l'instance générée par le fichier glade // vers la fenêtre courante xml->reparent_widget("vbox1", *this); // on connecte deux boutons b1.signal_clicked().connect(SigC::slot(*this, &Gtk::Window::hide)); b2.signal_clicked().connect(SigC::slot(*this, &Gtk::Window::hide)); // on ajoute les deux boutons précédents dans notre VBox qui // appartient à cette instance v->add(b1); v->add(b2); // on affiche tout le monde v->show_all_children(); } int main(int argc, char ** argv) { Gtk::Main application(&argc, &argv); Fenetre f; application.run(f); }