我有一个包含文件夹名称的文本文件。我想通过 Ubuntu 终端读取该文本文件的上下文并创建一个具有该名称的文件夹(写在 txt 文件中)。我不知道该怎么做,我创建了一个名为“in.txt”的文件,它的上下文是“name”,我尝试了下面的 c 代码:
#include <stdio.h>
int main(){
FILE *fopen (const char in.txt, const char r+);
}
我应该在终端中写什么?
最佳答案
设文本文件in.txt
为:
foldername1
foldername2
然后就可以创建一个脚本文件script.sh
:
#!/usr/bin/env bash
# $1 will be replaced with the first argument passed to the script:
mkdir -p $(cat "$1")
在 shell 中运行脚本:./script.sh in.txt
。 in.txt
中指定的文件夹名称现在应该可用。这假定 in.txt
中每行一个文件名,没有空格。
关于linux - 如何通过linux终端在文本文件中创建一个名为sth的文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49846611/