Category Archives: Scripting & programming

Somthing about Powershell, VB Script, C#, VB.NET

Git: Search in all versions of a file for a specific string

Hi,

to search in all versions of a file for a specfic string:
First get a list of all commits, then grep each commit:
Continue reading Git: Search in all versions of a file for a specific string

Git: Export all versions of a file within a given time range

Hi,

in some cases I uses git repositories for versioning log files and want to export a specific logfile in all versions:

for CommitHash in `git rev-list HEAD -- myFolder/myfile`; do
    git show ${CommitHash}:myFolder/myfile > export/${CommitHash}_myfile
done

combined with given time range

git  rev-list --after="2021-08-31" --until="2021-10-10" HEAD

and the the date of a commit in the filename

git show --format=%cd -s --date=format:'%Y%m%d-%H%M%S' 8dba4dd6ef44fe0c069ec87eb179ac8f8ae2222c

This should be this one:

export File=myFolder/myfile
export ExportFolder=/tmp
for CommitHash in `git rev-list --after="2021-11-01" --until="2021-11-16" HEAD -- $File`; do
    export CommitDate=$(git show --format=%cd -s --date=format:'%Y%m%d-%H%M%S' ${CommitHash})
    export ExportFileName=${ExportFolder}/${File}_${CommitDate}_${CommitHash} 
    echo Exporting $ExportFileName  
    git show ${CommitHash}:${File} > $ExportFileName
done

Michael

Powershell: Customize the prompt

Hi,

the default prompt of the powershell is “PS” and the current working directory:
Continue reading Powershell: Customize the prompt

Powershell: Run a (init) script when powershell starts

Hi,

if have some own aliases or functions defined which should be loaded when powershell starts you can create a startup script.
Continue reading Powershell: Run a (init) script when powershell starts

Windows: Working with the powershell command history

Hi,

like the UNIX bash shell, the Windows powershell also has a history which commands were executed.

Continue reading Windows: Working with the powershell command history