initial
This commit is contained in:
commit
74ae93a96e
1 changed files with 94691 additions and 0 deletions
59
joplin notion extension/linux/Extras/amber bash.md
Normal file
59
joplin notion extension/linux/Extras/amber bash.md
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
amber bash
|
||||
|
||||
https://docs.amber-lang.com/getting_started/getting_started
|
||||
|
||||
**installation**
|
||||
download its release and add binary to PATH env variable
|
||||
|
||||
**usage**
|
||||
`amber run main.ab` to simply run it
|
||||
|
||||
`amber build main.ab main.sh` to convert it into bash script
|
||||
`./main.sh`
|
||||
|
||||
**example**
|
||||
|
||||
```js
|
||||
// importing inbuilt methods for array and text variables
|
||||
import { split, slice } from "std/text"
|
||||
|
||||
const reduceFactor = 10
|
||||
|
||||
// this main function allows using arguments
|
||||
main(args){
|
||||
|
||||
echo(args[1])
|
||||
|
||||
// accepting first argument as folder. index 0 is just main.ab or bash
|
||||
const folder = args[1]
|
||||
|
||||
|
||||
// using commands and getting its output into text variable named 'res'
|
||||
let filesSortedByTimeStr = $ ls -t "{folder}" $ failed {echo(-1)}
|
||||
|
||||
// converting string to array with demiliter
|
||||
let filesSortedByTimeArray = split(filesSortedByTimeStr, "\n")
|
||||
|
||||
let abFilesSortedByTimeArray = []
|
||||
for index,file in filesSortedByTimeArray{
|
||||
|
||||
if slice(file, -4) == ".fos" {
|
||||
// add elements into array
|
||||
abFilesSortedByTimeArray+=[file]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const bufferFolder = "{folder}/tobedeleted"
|
||||
$ mkdir -p "{bufferFolder}" $ failed {echo("couldnt created tobedeleted folder")}
|
||||
for index,file in abFilesSortedByTimeArray{
|
||||
if index % reduceFactor != 0{
|
||||
$ mv "{folder}/{file}" "{bufferFolder}/" $ failed {}
|
||||
}
|
||||
}
|
||||
|
||||
let res = abFilesSortedByTimeArray
|
||||
$ echo {res} > output.txt $ failed{}
|
||||
}
|
||||
|
||||
```
|
||||
Loading…
Reference in a new issue