Question

Query on shell script

  • 23 September 2022
  • 1 reply
  • 30 views

Hi Team

I am looking for appending date and time timestamp  at end of each file in format <filename>_YYYYMMDDHH24MM.txt

Can someone help me how to achieve it in shell script?

[as per all ways EST, IST timings  etc]


1 reply

Userlevel 3
Badge +1

@Priyanka Mynepally 

 

#! /bin/sh
echo "Hello"

str=hello
echo $str
hr = 24
date_now=$(date "+%Y%m%d%H24%M")

echo ${str}__${date_now}.txt
 

Please try this and replace string variable with your filename .

Reply