ref: https://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
IFS=$(echo -en "\n\b")
for src_file in `find $rootpath -type f -name "* *" | grep -iE "\.($namefilter)" `; do
echo "src_file=" $src_file
done
IFS=$SAVEIFS
ref: https://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
1. add github remote url
git remote add github https://github.com/repo-name/testscript.git
git remote remove github https://github.com/repo-name/testscript.git
.git/config:[remote "github"]
url = https://github.com/repo-name/testscript.git2. add gitlab remote url
git remote add gitlab https://gitlab.com/repo-name/testscript.git
.git/config:[remote "gitlab"]
url = https://gitlab.com/repo-name/testscript.git
git branch -m feature/202203 main git fetch github
# set-upstream-to github/main mbp-main
git branch -u github/main mbp-main
#github/HEAD set to main
git remote set-head github -a
method1: $ : >test.csv
method2: cp /dev/null test.txt
method3: rm test.txt && touch test.txt
method4: sed -i -e 'd' test.txt
method5: truncate test.txt --size 0
$ truncate --help Usage: truncate OPTION... FILE... Shrink or extend the size of each FILE to the specified size A FILE argument that does not exist is created. If a FILE is larger than the specified size, the extra data is lost. If a FILE is shorter, it is extended and the extended part (hole) reads as zero bytes. Mandatory arguments to long options are mandatory for short options too. -c, --no-create do not create any files -o, --io-blocks treat SIZE as number of IO blocks instead of bytes -r, --reference=RFILE base size on RFILE -s, --size=SIZE set or adjust the file size by SIZE bytes --help display this help and exit --version output version information and exit SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000). SIZE may also be prefixed by one of the following modifying characters: '+' extend by, '-' reduce by, '<' at most, '>' at least, '/' round down to multiple of, '%' round up to multiple of. GNU coreutils online help: <http://www.gnu.org/software/coreutils/> For complete documentation, run: info coreutils 'truncate invocation'
method6: echo -n >test.txt #echo -n: do not output \n at the end.
ref:https://qiita.com/nabewata07/items/e67d008a1f10429bb3bf
ref:https://www.ibm.com/docs/ja/aix/7.1?topic=t-touch-command
touch: ファイルの時間属性を変更可能なコマンド:
ファイルのアクセス時刻と変更時刻を更新します。
touch [ -a ] [ -c ] [ -m ] [ -f ] [ -r RefFile ] [ Time | -t Time ] { File ... | Directory ... }
touch コマンドは、Directory パラメーターで指定された各ディレクトリー内の、File パラメーターで指定された各ファイルのアクセス時刻と修正時刻を更新します。Time 変数の値を指定しなければ、touch コマンドは現在の時刻を使用します。存在しないファイルを指定した場合は、 -c フラグで指定しない限り、 touch コマンドがその名前のファイルを作成します。
touch コマンドからの戻りコードは、時刻を修正できなかった (存在しなかったファイル、および作成されなかったファイルを含む) ファイル数です。
項目 | 説明 |
|---|---|
| -a | File 変数で指定されたファイルのアクセス時刻を変更します。-m が指定されていない限り、修正時刻は変更しません。 |
| -c | ファイルがまだ存在していない場合は、 ファイルを作成しません。 この条件に関する診断メッセージは書き出されません。 |
| -f | ファイルの読み取り許可と書き込み許可に関係なく、更新を強制的に実行しようとします。 |
| -m | File の修正時刻を更新します。-a が指定されていない限り、アクセス時刻は変更しません。 |
| -r RefFile | 現在時刻の代わりに、RefFile 変数で指定されたファイルの対応する時刻を使用します。 |
| Time | 新しいタイム・スタンプの日付と時刻を MMDDhhmm[YY] のフォーマットで指定します。
YY の桁の値が 70 から 99 までの場合は、年号の上 2 桁は 19 であると見なされます。 YY の桁の値が 00 から 37 までの場合は、年号の上 2 桁は 20 であると見なされます。 |
| -t Time | 現在時刻の代わりに指定された時刻を使用します。Time 変数は、10 進形式 [[CC]YY]MMDDhhmm[.SS] で指定されます。
|
# 先頭の行のみを出力
sed -n -e 1p
# 最後の行のみを出力
# \ はシェルのエスケープ
sed -n -e \$p
# 6行目から15行目を出力
sed -n -e 6,15p
# 奇数行のみを出力
sed -n -e 1~2p
# 1行目、6行目、11行目、16行目、、、を出力
sed -n -e 1~5p
# 正規表現にマッチする行を出力
sed -n -e /xxx/p
# これは以下と同じ
grep -e xxx
# 逆に正規表現にマッチしない行を出力(dコマンドでの例)
sed -e /xxx/d
# これは以下と同じ
grep -v -e xxx
# 正規表現にマッチする行を出力
# 先頭に \ を付ければ、正規表現を囲む記号はなんでもよい
sed -n -e '\%xxx%p'
# 1つ目の正規表現にマッチする行から2つ目の正規表現にマッチする行までを出力
sed -n -e /xxx/,/yyy/p
# 正規表現にマッチする行から3行分を出力
# 正規表現にマッチするごとに最低3行が出力される
sed -n -e /xxx/,+3p
# 正規表現にマッチする行から最後までを出力
# $ が最後という意味になる
sed -n -e '/xxx/,$p'
# 20行目から23行目までの4行分を出力
sed -n -e 20,+3p-- SELECT LOCKED INFO'SELECT SID
,SERIAL#
,SADDR
,MACHINE
,USERNAME
,PROGRAM
FROM V$SESSION
WHERE SID = ANY(SELECT SID
FROM V$LOCK
WHERE TYPE IN ('TX','TM') );
-- UNLOCK SESSION
ALTER SYSTEM KILL SESSION 'SID, SERIAL#';