0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

カレントディレクトリのファイル名を.txtで出力するshell script

Posted at

自分メモがてら

必要に迫られてカレントディレクトリ内のファイル名をテキストで出力する簡単なシェルスクを作ったのでメモ。"ディレクトリ名.txt"でデスクトップに保存される。

getname.sh
#!/bin/sh

DIRNAME=`echo ${PWD##*/}`

for f in *
do
echo ${f#*/} >> ~/Desktop/$DIRNAME.txt
done

実行権限を付与

bash
$ chmod u+x getname.sh

実行

bash
$ cd /path/to/dir
$ /path/to/getname.sh

happy!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?