comparison sed.xml @ 0:631dfde45073 draft default tip

First tool-shed public version
author gordon
date Tue, 09 Oct 2012 18:48:06 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:631dfde45073
1 <tool id="cshl_sed_tool" name="Sed" version="0.1.1">
2 <description></description>
3 <command>
4 sed --sandbox -r $silent -f '$sed_script' '$input1' &gt; '$output'
5 </command>
6 <inputs>
7 <param format="txt" name="input1" type="data" label="File to process" />
8
9 <param name="url_paste" type="text" area="true" size="5x35" label="SED Program" help="">
10 <sanitizer>
11 <valid initial="string.printable">
12 <remove value="&apos;"/>
13 </valid>
14 </sanitizer>
15 </param>
16
17 <param name="silent" type="select" label="operation mode" help="(Same as 'sed -n', leave at 'normal' unless you know what you're doing)" >
18 <option value="">normal</option>
19 <option value="-n">silent</option>
20 </param>
21
22 </inputs>
23 <configfiles>
24 <configfile name="sed_script">
25 $url_paste
26 </configfile>
27 </configfiles>
28 <outputs>
29 <data format="input" name="output" metadata_source="input1"
30 />
31 </outputs>
32 <help>
33
34 **What it does**
35
36 This tool runs the unix **sed** command on the selected data file.
37
38 .. class:: infomark
39
40 **TIP:** This tool uses the **extended regular** expression syntax (same as running 'sed -r').
41
42
43
44 **Further reading**
45
46 - Short sed tutorial (http://www.linuxhowtos.org/System/sed_tutorial.htm)
47 - Long sed tutorial (http://www.grymoire.com/Unix/Sed.html)
48 - sed faq with good examples (http://sed.sourceforge.net/sedfaq.html)
49 - sed cheat-sheet (http://www.catonmat.net/download/sed.stream.editor.cheat.sheet.pdf)
50 - Collection of useful sed one-liners (http://student.northpark.edu/pemente/sed/sed1line.txt)
51
52 -----
53
54 **Sed commands**
55
56 The most useful sed command is **s** (substitute).
57
58 **Examples**
59
60 - **s/hsa//** will remove the first instance of 'hsa' in every line.
61 - **s/hsa//g** will remove all instances (beacuse of the **g**) of 'hsa' in every line.
62 - **s/A{4,}/--&amp;--/g** will find sequences of 4 or more consecutive A's, and once found, will surround them with two dashes from each side. The **&amp;** marker is a place holder for 'whatever matched the regular expression'.
63 - **s/hsa-mir-([^ ]+)/short name: \\1 full name: &amp;/** will find strings such as 'hsa-mir-43a' (the regular expression is 'hsa-mir-' followed by non-space characters) and will replace it will string such as 'short name: 43a full name: hsa-mir-43a'. The **\\1** marker is a place holder for 'whatever matched the first parenthesis' (similar to perl's **$1**) .
64
65
66 **sed's Regular Expression Syntax**
67
68 The select tool searches the data for lines containing or not containing a match to the given pattern. A Regular Expression is a pattern descibing a certain amount of text.
69
70 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for.
71 - **^** matches the beginning of a string(but not an internal line).
72 - **(** .. **)** groups a particular pattern.
73 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern.
74
75 - **{n}** The preceding item is matched exactly n times.
76 - **{n,}** The preceding item ismatched n or more times.
77 - **{n,m}** The preceding item is matched at least n times but not more than m times.
78
79 - **[** ... **]** creates a character class. Within the brackets, single characters can be placed. A dash (-) may be used to indicate a range such as **a-z**.
80 - **.** Matches any single character except a newline.
81 - ***** The preceding item will be matched zero or more times.
82 - **?** The preceding item is optional and matched at most once.
83 - **+** The preceding item will be matched one or more times.
84 - **^** has two meaning:
85 - matches the beginning of a line or string.
86 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets.
87 - **$** matches the end of a line or string.
88 - **\|** Separates alternate possibilities.
89
90
91 **Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported.
92
93 </help>
94 </tool>