我是 Linux 新手,目前正在尝试运行使用 Windows 10 Linux 子系统操作文件(代码片段)的 Bash Shell 脚本(参见最底部),但脚本在步骤 5(第 32 行)一直失败并始终显示下面的错误。
Error: ‘./snippets_filter.sh: line 32: q-text-as-data: command not found’.
我尝试了以下方法:
q-text-as-data
使用以下命令重新安装:sudo apt-get update -y
和sudo apt-get install -y q-text-as-data
。- 使用以下命令列出所有软件包以验证安装:
dpkg -l | less
。我可以看到它q-text-as-data
位于 python 下,如python3-q-text-as-data
列表中所示。 q-text-as-data
我也尝试将和的位置打印python3-q-text-as-data
到终端,但这些位置都是空的。
有人知道问题是什么吗?我该如何让 Line 32 运行?
感谢您的时间。
#/bin/bash
set -eu
if [ $# -ne 1 ]; then
echo $0: usage: bash snippets_filter.sh snippets_dir
exit 1
fi
SNIPPETS_BASE_DIR=$1
TMP_KW=".snips_w_kw"
TMP_SYM=".snips_w_sym"
TMP_KW_SYM=".snips_w_sym_kw"
TMP_KW_SYM_LC=".snips_w_sym_kw_lc"
FULL_FILE="snips_sym_kw_6lines"
FULL_FILE_ID="snips_sym_kw_6lines_id"
echo "# Step 1/6 - Gathering list of snippets with keywords [ print or import ]"
grep -e 'print' -e 'import' -w -l -r "${SNIPPETS_BASE_DIR}" > "${TMP_KW}"
echo "# Step 2/6 - Gathering list of snippets with symbols [ ( or = ]"
grep -e '(' -e '=' -l -r "${SNIPPETS_BASE_DIR}" > "${TMP_SYM}"
echo "# Step 3/6 - Combining list of snippets with symbols or keywords"
cat "${TMP_KW}" "${TMP_SYM}" | sort -u > "${TMP_KW_SYM}"
echo "# Step 4/6 - Gathering line counts of those snippets (this will take a while)"
cat "${TMP_KW_SYM}" | xargs -I{} -n1 sh -c 'echo -n "{} "; grep -c . {}' > "${TMP_KW_SYM_LC}"
echo "# Step 5/6 - Getting list of IDs with > 6 lines and containing symbols and keywords"
q-text-as-data "select x.c1 from ${TMP_KW_SYM_LC} x where x.c2 > 5" > "${FULL_FILE}"
cat "${FULL_FILE}" | rev | cut -d'/' -f1 | cut -d'.' -f2 | rev > "${FULL_FILE_ID}"
echo "# Step 6/6 - Cleanup - Removing tmp files"
rm "${TMP_KW}" "${TMP_SYM}" "${TMP_KW_SYM}" "${TMP_KW_SYM_LC}"