Find files having todays date and hostname in its name.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find files having todays date and hostname in its name.
# 1  
Old 03-17-2011
Find files having todays date and hostname in its name.

Hello,
I am quite new to unix/shell and want to write a script using bash which will process the files.
Basically i want to search files having name as "date+hostname+somestring.out"

i am using below variables and then will use them in find command :-
Code:
TODAY_DATE=$('date +%d')
HOSTNAME=$('uname -n')

but i get error as below:-
Code:
date +%d: command not found
uname -n: command not found

Can anybody guess whats wrong in this or any other better way?

Last edited by Franklin52; 03-17-2011 at 06:43 AM.. Reason: Please use code tags, thank you
# 2  
Old 03-17-2011
Code:
ls $(date +%d)$(uname -n)*.out

# 3  
Old 03-17-2011
Thanks a lot for the quick and easy solution!!!
# 4  
Old 03-17-2011
how to post my queries

hi apm, pravin27,

apologies for asking this quetion here...
i want to post my query in a new thread... but i m not able to get how to post a new query...
can you help me in this???

regards,
Swapnil
# 5  
Old 03-17-2011
U can start new thread, goto Forums -> Select the forum related to ur problem -> Click NewThread button on Top-Left corner.

Thanks
# 6  
Old 03-17-2011
thank you apm... i got it...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find todays files

I am trying to find todays files only in the "root directories like /etc, /opt etc. I do not want to search in my home directory or any of its subdirectories. That's hard because a directory listing does not show the year? -rw------- 1 andy andy 22487 Oct 12 13:40 .xsession-errors ... (8 Replies)
Discussion started by: drew77
8 Replies

2. Shell Programming and Scripting

Shell script to compare two files of todays date and yesterday's date

hi all, How to compare two files whether they are same are not...? like i had my input files as 20141201_file.txt and 20141130_file2.txt how to compare the above files based on date .. like todays file and yesterdays file...? (4 Replies)
Discussion started by: hemanthsaikumar
4 Replies

3. UNIX for Dummies Questions & Answers

Help in script to check file name with todays date

I am trying to include a snippet in my script to check if the file created is having today's date. eg: File name is : ABC.YYYYMMDD-nnn.log The script should check if 'YYYYMMDD' in the above file name matches with today's date. Can you please help me in achieving this. Thanks in advance!! (5 Replies)
Discussion started by: kiran1112
5 Replies

4. UNIX for Dummies Questions & Answers

Make directory with todays date format

Not sure why this is not working. Please advice: #!/bin/sh DIR=`date +"%m-%d-%y"` echo $DIR ] && mkdir $DIR (2 Replies)
Discussion started by: iaav
2 Replies

5. Shell Programming and Scripting

Find and copy files based on todays date and search for a particular string

Hi All, I am new to shell srcipting. Problem : I need to write a script which copy the log files from /prod/logs directory based on todays date like (Jul 17) and place it to /home/hzjnr0 directory and then search the copied logfiles for the string "@ending successfully on Thu Jul 17". If... (2 Replies)
Discussion started by: mail.chiranjit
2 Replies

6. Shell Programming and Scripting

Need help in Shell Script comparing todays date with Yesterday date from Sysdate

Hi, I want to compare today's date(DDMMYYYY) with yesterday(DDMMYYYY) from system date,if (today month = yesterday month) then execute alter query else do nothing. The above requirement i want in Shell script(KSH)... Can any one please help me? Double post, continued here. (0 Replies)
Discussion started by: kumarmsk1331
0 Replies

7. Shell Programming and Scripting

Shell script help to eliminate files of todays date

Hi I am very new to shell scripting and have written a script (below). However the directory I am searching will contain a file with a .trn extension each day which I want to eliminate. Each day the file extension overnight will change to trx, if this fails I want to know. Basically what I... (2 Replies)
Discussion started by: richM
2 Replies

8. Linux

Comparing the file drop date with todays date

Daily one file will dropped into this directory. Directory: /opt/app/jt/drop File name: XXXX_<timestamp>.dat.gz I need to write a script which checks whether the file is dropped daily or not. Any idea in the script how can we compare timestamp of the file to today's date?? (3 Replies)
Discussion started by: Rajneel
3 Replies

9. Shell Programming and Scripting

using todays date to create a report using grep

What i'm trying to do is to use grep to search through a few files for a selected daemon and only report on today's date. I think I got it sorted apart from in the txt file the date has 2 gaps between the month and the day, and the way I have the date format only puts in one gap any help to get... (3 Replies)
Discussion started by: MBN
3 Replies

10. UNIX for Dummies Questions & Answers

Get yesterdays date given todays date

Hi Guys. I am very new to UNIX. I need to get yesterdays and tommorows date given todays date. Which command and syntax do i use in basic UNIX shell. Thanks. (2 Replies)
Discussion started by: magikminox
2 Replies
Login or Register to Ask a Question