Skip to content

Commit ea1ffa8

Browse files
author
⚙︎ Greg
committed
0.0.4
1 parent 7e86a26 commit ea1ffa8

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# FsShell
22
List of Shell-like commands for use in F#.
33

4+
I commonly work with data files in the legal space, so wanted a set of commands that I could use for quicker data manipulation and investigation.
5+
46
## Caveat
57
These commands are NOT intended for projects with a long life. It is recommended that this only be used in the FSI or for short fire-and-forget utilities. As I eat my own dog food and become more proficient in idiomatic F#, some things might change.
68

@@ -13,6 +15,8 @@ man "";;
1315

1416
[All functions are in FsShell.fs](src/FsShell/FsShell.fs)
1517

18+
Note: Most functions work with `seq<string>`. Functions prefixed with an 'x' work with `seq<string[]>`
19+
1620
```
1721
System
1822
cd Change directory
@@ -21,7 +25,7 @@ System
2125
mv Move file
2226
cp Copy file
2327
ls List
24-
ll List with details (fullname * size * FileInfo)
28+
ll List with details
2529
find Find files
2630
find_p Find folders
2731
Output
@@ -33,12 +37,18 @@ Output
3337
tee_a Append to a file and passthrough
3438
cat Read a list of files consecutively
3539
Data Manipulation
36-
NOTE: these will create seq<string list> that aren't friendly with other commands
3740
cut Split lines at tabs
3841
cut_d Split lines at delimeter
3942
cut_c Cut character range options
4043
cut_c2 Cut character ranges
41-
cutx Splits data file into columns
44+
cut_x Splits data file into columns
45+
xjoin Join columns into data
46+
sort Sorting
47+
sort_k Sorting by a substring
48+
sort_kn Sorting by a substring as a number
49+
xsort Sorting by columns
50+
xsort_n Sorting by columns, each as a number
51+
xsort2 Sorting by columns, specify as string or number
4252
Data Flow
4353
grep Filter lines to include
4454
grep_i Filter lines to include, case insensitive
@@ -48,6 +58,14 @@ Data Flow
4858
grep_in Filter lines to exclude, case insensitive
4959
egrep_n Filter lines to exclude with regex
5060
egrep_in Filter lines to exclude with regex, case insensitive
61+
xgrep Filter on a pattern in specified columns
62+
xgrep_i Filter on a case-insensitive pattern in specified columns
63+
xgrep_n Inverted filter on a pattern in specified columns
64+
xgrep_in Inverted filter on a case-insensitive pattern in specified columns
65+
xegrep Filter on a regex in specified columns
66+
xegrep_i Filter on a case-insensitive regex in specified columns
67+
xegrep_n Inverted filter on a regex in specified columns
68+
xegrep_in Inverted filter on a case-insensitive regex in specified columns
5169
head_n First count lines
5270
head First 10 lines
5371
tail_n Last count lines, or skip first count of lines
@@ -118,6 +136,17 @@ val it: seq<string array> =
118136
[|"Val 1-3"; "Val 2-3"; "Val 3-3"|]]
119137
```
120138

139+
### Data Investigation
140+
```F#
141+
> // Used this command to find duplicate values
142+
- cat [ "file.dat" ]
143+
- |> cutx // parse the file
144+
- |> Seq.map (fun cols -> cols[0]) // get data from the first column
145+
- |> Seq.groupBy id // grouping by first column
146+
- |> Seq.map (fun (docid, docids) -> (docid, Seq.length docids)) // docid, count of docids
147+
- ;;
148+
```
149+
121150
## Miscellaneous
122151

123152
### "Why no rm and rmdir?"

src/FsShell/FsShell.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PackageId>FsShell</PackageId>
66
<PackageLicenseExpression>MIT</PackageLicenseExpression>
77
<PackageReadmeFile>README.md</PackageReadmeFile>
8-
<Version>0.0.3</Version>
8+
<Version>0.0.4</Version>
99
<Authors>Greg H</Authors>
1010
<Product>FsShell</Product>
1111
<PackageProjectUrl>https://github.com/SpiralOSS/FsShell</PackageProjectUrl>

0 commit comments

Comments
 (0)