|
2 | 2 |
|
3 | 3 | ## Data types
|
4 | 4 |
|
5 |
| -convert string to integer: `"12" | into int` |
| 5 | +convert string to integer: |
6 | 6 |
|
7 |
| -convert present date to provided time zone: `date now | date to-timezone "Europe/London"` |
| 7 | +```nu |
| 8 | +"12" | into int |
| 9 | +``` |
| 10 | + |
| 11 | +convert present date to provided time zone: |
| 12 | + |
| 13 | +```nu |
| 14 | +date now | date to-timezone "Europe/London" |
| 15 | +``` |
| 16 | + |
| 17 | +update a record's language and if none is specified insert provided value: |
| 18 | + |
| 19 | +```nu |
| 20 | +{'name': 'nu', 'stars': 5, 'language': 'Python'} | upsert language 'Rust' |
| 21 | +``` |
8 | 22 |
|
9 |
| -update a record's language and if none is specified insert provided value: `{'name': 'nu', 'stars': 5, 'language': 'Python'} | upsert language 'Rust'` |
| 23 | +convert list of strings to yaml: |
10 | 24 |
|
11 |
| -convert list of strings to yaml: `[one two three] | to yaml` |
| 25 | +```nu |
| 26 | +[one two three] | to yaml |
| 27 | +``` |
| 28 | + |
| 29 | +print table data: |
12 | 30 |
|
13 |
| -print table data: `[[framework, language]; [Django, Python] [Laravel, PHP]]` |
| 31 | +```nu |
| 32 | +[[framework, language]; [Django, Python] [Laravel, PHP]] |
| 33 | +``` |
14 | 34 |
|
15 | 35 | select two named columns from the table and print their values:
|
16 | 36 |
|
@@ -233,9 +253,17 @@ slice items that satisfy provided condition:
|
233 | 253 |
|
234 | 254 | ## Tables
|
235 | 255 |
|
236 |
| -sort table: `ls | sort-by size` |
| 256 | +sort table: |
237 | 257 |
|
238 |
| -sort table, get first rows: `ls | sort-by size | first 5` |
| 258 | +```nu |
| 259 | +ls | sort-by size |
| 260 | +``` |
| 261 | + |
| 262 | +sort table, get first rows: |
| 263 | + |
| 264 | +```nu |
| 265 | +ls | sort-by size | first 5 |
| 266 | +``` |
239 | 267 |
|
240 | 268 | concatenate two tables with same columns:
|
241 | 269 |
|
@@ -268,17 +296,41 @@ remove the last column of a table:
|
268 | 296 |
|
269 | 297 | ## Files & Filesystem
|
270 | 298 |
|
271 |
| -open a text file with the default text editor: `start file.txt` |
| 299 | +open a text file with the default text editor: |
| 300 | + |
| 301 | +```nu |
| 302 | +start file.txt |
| 303 | +``` |
| 304 | + |
| 305 | +save a string to text file: |
272 | 306 |
|
273 |
| -save a string to text file: `'lorem ipsum ' | save file.txt` |
| 307 | +```nu |
| 308 | +'lorem ipsum ' | save file.txt |
| 309 | +``` |
274 | 310 |
|
275 |
| -append a string to the end of a text file: `'dolor sit amet' | save --append file.txt` |
| 311 | +append a string to the end of a text file: |
276 | 312 |
|
277 |
| -save a record to file.json: `{ a: 1, b: 2 } | save file.json` |
| 313 | +```nu |
| 314 | +'dolor sit amet' | save --append file.txt |
| 315 | +``` |
278 | 316 |
|
279 |
| -recursively search for files by file name: `glob **/*.{rs,toml} --depth 2` |
| 317 | +save a record to file.json: |
280 | 318 |
|
281 |
| -watch a file, run command whenever it changes: `watch . --glob=**/*.rs {|| cargo test }` |
| 319 | +```nu |
| 320 | +{ a: 1, b: 2 } | save file.json |
| 321 | +``` |
| 322 | + |
| 323 | +recursively search for files by file name: |
| 324 | + |
| 325 | +```nu |
| 326 | +glob **/*.{rs,toml} --depth 2 |
| 327 | +``` |
| 328 | + |
| 329 | +watch a file, run command whenever it changes: |
| 330 | + |
| 331 | +```nu |
| 332 | +watch . --glob=**/*.rs {|| cargo test } |
| 333 | +``` |
282 | 334 |
|
283 | 335 | ## Custom Commands
|
284 | 336 |
|
|
0 commit comments