Skip to main content
Question

Query on shell script

  • September 23, 2022
  • 1 reply
  • 86 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

Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • September 23, 2022

@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 .