SCRIPTING

How to find script file name in a Bash script?

Sometime we want to know the file name of the script which we are executing in bash scripting. One such scenarios is use the file name for logging purpose, without hardcoding the name of the script file. In the below example, readlink prints out the value of a symbolic link. [...]

2021-04-06T12:45:57+05:30Categories: Linux|Tags: |

Generate file name with timestamp in windows batch file

This tutorial describes a simple .bat file used to create timestamp. @echo off For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b) For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b) echo %mydate%_%mytime% If you want the date independently of the region day/month order, you [...]

2017-10-08T13:43:13+05:30Categories: Windows|Tags: |

Add comment in a batch/cmd

The rem command is indeed for comments. It doesn't inherently update anyone after running the script. Because by default the batch interpreter will print out each command before it's processed, to avoid printing a command, prefix it with @, or, to apply that setting throughout the program, run @echo off. (It's echo off to avoid printing further commands; [...]

2017-10-08T13:43:18+05:30Categories: Windows|Tags: |

Pass command line parameters to a batch file

Pass parameters separated by space, and assign each argument to variable as shown below. Use %* to mean "all". For example, echo off set arg1=%1   // First parameter set arg2=%2 shift shift some-command /u %arg1% /p %arg2% %* When you run: test-command admin password foo bar the above batch [...]

2017-10-08T13:36:54+05:30Categories: Windows|Tags: |
Go to Top