write.sh
#! /bin/shset-euo pipefailforiin{1..100};doecho"$i"sleep1done
main.go
packagemainimport("bufio""encoding/base64""log""os")funcmain(){l:=log.New(os.Stdout,"[STREAM] ",log.Lshortfile|log.LstdFlags|log.Lmsgprefix)s:=bufio.NewScanner(os.Stdin)fors.Scan(){t:=s.Text()b:=s.Bytes()// for example process the input to b64b64:=base64.StdEncoding.EncodeToString(b)l.Println(t,"=>",b64)}}
Usage
sh write.sh | go run main.go2022/04/10 20:55:25 main.go:20:[STREAM] 1=>MQ==2022/04/10 20:55:26 main.go:20:[STREAM] 2=>Mg==2022/04/10 20:55:27 main.go:20:[STREAM] 3=>Mw==2022/04/10 20:55:28 main.go:20:[STREAM] 4=>NA==2022/04/10 20:55:29 main.go:20:[STREAM] 5=>NQ==2022/04/10 20:55:30 main.go:20:[STREAM] 6=>Ng==^Csignal: interrupt
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse