script, , , :
#!/bin/bash
while read line; do
set $line
IFS=' ' read -a array <<< "$line"
for str in ${array[@]}; do
if [[ "$str" =~ [A-Z]{5} ]]; then
echo curl "http://example.com/api_call/$str"
fi
done
done < raw.txt
EDIT: URL, URI. , , , do_something "$ (curl...)"
EDIT2: bash, , :
bash, , , - , .
- , , . shift . , tmp curl- , .
removed temporarily to avoid confusion
3: . . .
EDIT4:
#!/bin/bash
while read line; do
set $line
IFS=' ' read -a array <<< "$line"
i=0
echo "Array before processing: ${array[@]}"
for str in ${array[@]}; do
if [[ "$str" =~ [A-Z]{5} ]]; then
curl="$(echo 1234 -1234)"
if [[ "$flag" = "1" ]]; then
array=( ${adjustedArray[@]} )
push=$(( $push + 2 ));
let i++
else
push=1
fi
adjustedArray=( ${array[@]:0:$i} ${curl[@]} ${array[@]:$(( $i + $push)):${#array[@]}} )
flag=1;
fi
let i++
done
unset flag
echo "final: ${adjustedArray[@]}"
done < raw.txt
, , , bash, - . , , - .
, ,
ps - , , script , . Perl, php python