我想在文件中写一个带有ANSI代码的单词,但着嘴将其删除,从而仅将单词绑住
job.sh
#!/bin/bash
#SBATCH --job-name=test
#SBATCH --nodes=1 # number of nodes
#SBATCH --ntasks-per-node=1 # number of cores
#SBATCH --time=24:00:00 # walltime
#SBATCH --output=out.txt
#SBATCH --error=err.txt
module load R
Rscript test.R
test.R
library(crayon)
fileConn<-file("output.txt")
x <- as.character(yellow("hello world"))
writeLines(x, fileConn)
close(fileConn)
output.txt
hello world
# i want this \033[33mhello wrold\033[39m
当我仅使用Rscript命令时,它可以按我希望的方式工作(它在output.txt文件中写入ANSI代码),但是如果我使用sbatch job.sh命令进行slurm,则不会编写代码ANSI。