<rdf:RDF
    xmlns:s='http://snipsnap.org/rdf/snip-schema#'
    xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    xml:base='http://www.stefanrufer.ch/snipsnap/rdf'>
    <s:Snip rdf:about='http://www.stefanrufer.ch/snipsnap/rdf#Virtual+Brain/Linux/text+operations'
         s:cUser='stefan'
         s:oUser='stefan'
         s:mUser='stefan'>
        <s:name>Virtual Brain/Linux/text operations</s:name>
        <s:content>1 sort listing numerically&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;ls -1&#xD;&#xA;1.txt&#xD;&#xA;10.txt&#xD;&#xA;2.txt&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;but&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;ls -1 | sort -n&#xD;&#xA;1.txt&#xD;&#xA;2.txt&#xD;&#xA;10.txt&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;:-) &#xD;&#xA;&#xD;&#xA;1 column moving&#xD;&#xA;&#xD;&#xA;Will take file and print the (whitespace separated? didn&apos;t check this) first two columns of each line in reversed order (first column 2 then column 1).&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;awk &apos;{ print $2 $1 }&apos; file&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;1 column selection&#xD;&#xA;&#xD;&#xA;Print only second to third column of comma separated text in file.&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;cut -f 2-3 -d , file&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;1 replace text in multiple files&#xD;&#xA;&#xD;&#xA;Perl offers the easiest way to do in-place-editing of text files:&#xD;&#xA;{code:none}&#xD;&#xA;perl -pi -e &apos;s/tobereplaced/withthis/&apos; filename&#xD;&#xA;# for the cautious people: make backups before editing the file:&#xD;&#xA;perl -pi&apos;.bak&apos; -e &apos;s/tobereplaced/withthis/&apos; filename&#xD;&#xA;# therefore multiple files:&#xD;&#xA;find . -name filename -exec perl -pi -e &apos;s/pattern/bar/&apos; {} \;&#xD;&#xA;&#xD;&#xA;# same with sed (in place edit, extended regex)&#xD;&#xA;sed -i -r &quot;s/tobereplaced/withthis/&quot; filename&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;It&apos;s possible to use other characters than / to delimit the patterns, e.g. pipe (|) or semicolon. This helps if the pattern itself contains slashes. Note that pattern is a regexp.&#xD;&#xA;&#xD;&#xA;Thanks also to Stefan Tramm for this hints :-)&#xD;&#xA;&#xD;&#xA;http://hacks.oreilly.com/pub/h/73&#xD;&#xA;&#xD;&#xA;Replacing several things in a file with the above shorthand can be time consuming as a new perl process is started for every file and every replacement. An elegant way is to use a script that contains all the replacement commands - for sure this works with perl, but I usually use sed for this:&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;# sed script &apos;deprecation-off.sed&apos; could look like this:&#xD;&#xA;s/org.eclipse.jdt.core.compiler.problem.deprecation=warning/org.eclipse.jdt.core.compiler.problem.deprecation=ignore/&#xD;&#xA;s/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled/&#xD;&#xA;&#xD;&#xA;# and a call to edit all eclipse settings files could look like this:&#xD;&#xA;find ./*/.settings -name org.eclipse.jdt.core.prefs -print -exec sed -i -f deprecation-off.sed {} \;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;1 bash string operations&#xD;&#xA;&#xD;&#xA;Just a few but really useful:&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;# length of a string&#xD;&#xA;${#string}&#xD;&#xA;&#xD;&#xA;# some examples&#xD;&#xA;&gt; echo ${USER}&#xD;&#xA;stefan&#xD;&#xA;&gt; echo ${#USER}&#xD;&#xA;6&#xD;&#xA;&gt; echo ${USER:2}&#xD;&#xA;efan&#xD;&#xA;&gt; echo ${USER:2:1}&#xD;&#xA;e&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Source: http://tldp.org/LDP/abs/html/&#xD;&#xA;&#xD;&#xA;</s:content>
        <s:mTime>2011-03-29 12:30:51.757</s:mTime>
        <s:cTime>2005-01-12 21:28:01.54</s:cTime>
        <s:comments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
        <s:snipLinks>
            <rdf:Bag>
                <rdf:li rdf:resource='http://www.stefanrufer.ch/snipsnap/rdf#Virtual Brain/Linux'/>
                <rdf:li rdf:resource='#snipsnap-index'/>
                <rdf:li rdf:resource='http://www.stefanrufer.ch/snipsnap/rdf#Virtual Brain'/>
                <rdf:li rdf:resource='http://www.stefanrufer.ch/snipsnap/rdf#Virtual+Brain/Linux'/>
                <rdf:li rdf:resource='#adrian'/>
                <rdf:li>
                    <s:Snip rdf:about='http://www.stefanrufer.ch/snipsnap/rdf#Virtual+Brain/Linux/text+operations'>
                        <s:attachments
                             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
                    </s:Snip>
                </rdf:li>
            </rdf:Bag>
        </s:snipLinks>
    </s:Snip>
</rdf:RDF>

