-
multiple stdin to single output
$ cat test.dat Test Multiple input $ cat test.dat | ./multiple_stdin_to_single_output.sh Test Multiple input $ cat multiple_stdin_to_single_output.sh #!/bin/sh myvar=`cat` echo $myvar
-
multiple stdin to multiple output
$ cat test.dat | ./multiple_stdin_to_multiple_output.sh Test Multiple input $ cat multiple_stdin_to_multiple_output.sh #!/bin/sh while read query do echo $query done
-
-
Save hyunjun/c8aa8398b60b366177385e8dc36d677d to your computer and use it in GitHub Desktop.
bash stdin
-
multiple stdin to output splitted by tab
$ cat test.query 갤빈클라인 캘빈클라인 제첩국 재첩국 $ cat test.query | ./test.sh 갤빈클라인 캘빈클라인 갤빈클라인 캘빈클라인 제첩국 재첩국 제첩국 재첩국 $ cat test.sh #!/bin/sh while read query do echo "$query" norm="${query%$'\t'*}" oup="${query##*$'\t'}" echo $norm echo $oup done
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
url='https://www.abc.com/123' | |
echo $url | |
protocol_removed=${url##*:} | |
echo $protocol_removed | |
slash_removed=${protocol_removed:2:${#protocol_removed}} | |
echo $slash_removed | |
slash_changed=${slash_removed/\//-} | |
echo $slash_changed | |
# Result | |
# https://www.abc.com/123 | |
# //www.abc.com/123 | |
# www.abc.com/123 | |
# www.abc.com-123 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment