我有这个代码
#!/bin/bash
function emotion() {
#here is function code end with return value...
echo $1
}
export -f emotion
#I've put all animals in array
animalList=($(awk '{print $1}' animal.csv))
#loop array and grep all the lines form the file
for j in ${animalList[@]}
do
: #here I'am running a bash script calling emotion function
grep $j animal.csv | awk '{for(i=2;i<=NF;i++){system("bash -c '\''emotion "$i"'\''")}}'
done
Run Code Online (Sandbox Code Playgroud)
我有这个文件:
cat smile happy laugh
dog angry sad
mouse …
Run Code Online (Sandbox Code Playgroud)