LoginSignup
0
1

More than 5 years have passed since last update.

bash > string > ファイル名の先頭文字数を指定して表示 > cut -b "-4"

Last updated at Posted at 2018-02-02
動作環境
Xeon E5-2620 v4 (8コア) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 とその-devel
mpich.x86_64 3.1-5.el6とその-devel
gcc version 4.4.7 (とgfortran)
NCAR Command Language Version 6.3.0
WRF v3.9を使用。
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) 
Python 3.6.0 on virtualenv
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
date (GNU coreutils) 8.4 
tmux 1.6-3.el6

bash > bundle_similar_file_180202_exec > 似たようなファイル名の一覧を省略表示するスクリプト v0.1, v0.2 > スクリプトでなく「ls | uniq -w 3」でいい
において文字列処理をしていたところ、@tukiyo3 さんに文字列の切り取り方を教えていただきました

将来の再利用性を考慮して、別記事に切り出します。

教えていただいたコード

こちらを参照ください。

$ ls
AAA01  AAA02  AAA03  BBB01  BBB02  BBB03  BBB04  bundle_similar_file_180202_exec  CCC01
$ bundle_similar_file_180202_exec 3
AAA
BBB
bun
CCC

0
1
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
1