Bash脚本中的问题内存分配

问题描述 投票:1回答:2

我试图自动清理与我合作的各种单词表的过程。这是下面的代码:

#!/bin/bash
# Removes spaces and duplicates in a wordlist


echo "Please be in the same directory as wordlist!"
read -p "Enter Worldlist: " WORDLIST
RESULT=$( awk '{print length, $0}' $WORDLIST | sort -n | cut -d " " -f2- )
awk '!(count[$0]++)' $RESULT > better-$RESULT

这是运行程序后收到的错误:

./wordlist-cleaner.sh: fork: Cannot allocate memory

第一篇文章,希望我格式化正确。

bash text memory-management scripting fork
2个回答
1
投票
awk '{print length, $0}' "$WORDLIST" | sort -n | cut -d " " -f2- | uniq > better-RESULT

请注意,它是better-RESULT而不是better-$RESULT,因为您不想将其用作文件名。


0
投票
© www.soinside.com 2019 - 2024. All rights reserved.