23
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

よく使うシェルスクリプト

Last updated at Posted at 2015-06-12
自分のディレクトリに移動
#!/bin/sh

cd `dirname $0`
list.txtを一行づつ読み込んでループ
filename="list.txt"
cat ${filename} | while read -r line
do
  echo $line
done
ワイルドカードで検索したファイルリストをループ

files="*.txt"
for filepath in ${files}
do
  echo $filepath
done
ディレクトリ内にある.pngファイルを原色する
#!/bin/bash

# 処理対象のディレクトリ(カレントディレクトリの場合は . を指定)
TARGET_DIR="."

# ディレクトリ内のすべての .png ファイルを処理
find "$TARGET_DIR" -type f -name "*.png" | while read -r file; do
  # pngquantで減色処理し、元ファイルに上書き
  pngquant --quality=65-80 --force --output "$file" "$file"
done

パス文字列からファイル名などを抜き出す

23
25
5

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
23
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?