-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
echo "在下方貼上文字。按 Ctrl+D 結束輸入:" | ||
|
||
# 讀取多行輸入 | ||
input=$(cat) | ||
|
||
# 使用 sed 擷取 URL | ||
urls=$(echo "$input" | sed -En 's/.*((https?:\/\/)[^ )]*)[ )].*/\1/gp') | ||
|
||
# 檢查是否找到 URL | ||
if [ -n "$urls" ]; then | ||
echo -e "\n擷取到的 URL:" | ||
echo "$urls" | ||
else | ||
echo -e "\n在輸入的文字中沒有找到 URL。" | ||
fi |