Shell

From Wiki at Neela Nurseries
Revision as of 19:19, 31 January 2024 by Ted (talk | contribs) (Add helper bash script for use with "git diff-tree")
Jump to: navigation, search

Shell Scripting

^ OVERVIEW

This local page for Bash shell scripts and notes on shell scripting.

^ Rename Badly Named Files

How to produce a usable filename which contains <ESC> characters, and to rename that badly named file:

 $ ls -i
 9704871 $'\033\033'   9703029  CMakeLists.txt  10899590  dts          9708845  samples
 $ ls -q `find . -inum 9704871`
 './'$'\033\033'
 $ mv './'$'\033\033' betterfilename

^ Git Diff-tree Helper Script

A helper script for calling `git diff-tree`, which can be used to determine at which project commit one or more files have changed:


#!/bin/bash

CMD_GIT=/usr/bin/git

$CMD_GIT log --oneline | head | cut -d " " -f 1

echo "2024-01-31 git diff-tree helper script in progress . . ."

hashes=`$CMD_GIT log --oneline | head | cut -d " " -f 1`
echo "In $PWD found git commit hashes:"
echo " " $hashes

#i=1
#for hash in $hashes; do echo "("$i")" $hash; (( i++ )); done

#echo "Files changed between commit pairs youngest pairings to oldest:
for hash in $hashes; do echo "Files changed in git commit:"; git diff-tree -r $hash; echo; done

echo "done"

exit 0