Script pick elements according to the date in file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script pick elements according to the date in file
# 8  
Old 01-16-2013
Remove the double quotes inside:-
Code:
grep "$( date +%d-%b )" File.txt

# 9  
Old 01-17-2013
Still not working showing same Error

Code:
grep "$(date +%d-%b)" rnc.txt

Output
Illegal variable name.
# 10  
Old 01-17-2013
Code:
 
a=`date| cut -c1-6`
grep "$a" filename

# 11  
Old 01-17-2013
rajjev_saini123, what SHELL & OS?
Code:
echo $SHELL

Code:
uname

# 12  
Old 01-17-2013
Full code and other details

I have written the complete code now it shows syntax erro

Code:
CWD=/home/test/Bench
cd $CWD
(grep "`date +%d-%b"`" File.txt) >  /home/test/Bench/dateout
if [ -s / home/test/Bench/dateout ]
then
echo “data”  > /home/test/ Bench /test
else
echo "File Empty"
cat /home/test/ Bench /test > /home/test/ Bench /resultest
awk '!/get/' resultest > /home/test/ Bench/output
awk '!/0x000/' resultest > /home/test/Bench/output1
if [ -s /home/test/ Bench/output1 ]
then
MAILTO="raj@yahoo.co.in"
CONTENT="/home/test/ Bench /output1"
(
echo "Subject: Test"
echo "MIME-Version: 1.0"
echo "Content-Type: text/plain"
echo "Content-Disposition: inline"
cat $CONTENT
) | /usr/sbin/sendmail -t $MAILTO
fi
else
echo "bbb"
fi 


SunOS
/usr/bin/tcsh
# 13  
Old 01-17-2013
Ok, will not work in tcsh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Should pick latest file within past 3 days using UNIX script and perform steps in message below.

Hi , Can anyone help me how do perform below requirement in unix. Step1:we will receive multiple files weekly with same name(as below) in a folder(In folder we will have other files also def.dat,ghf.dat) Filenames: 1) abc_20171204_052389.dat 2)abc_20171204_052428.dat DON'T modify... (23 Replies)
Discussion started by: sunnykamal59
23 Replies

2. Shell Programming and Scripting

Needs perl script - pick right file name

Hi., I need in perl type ...where this is an example : assume a directory has 3 files namely: file1_1445566_201501022.txt file1_1445566_201502024.txt file1_1445566_201503009.txt where ,after second underscore, the number is in YYYYMMDD time-stamp format, I need perl script to pick up... (3 Replies)
Discussion started by: alnhk
3 Replies

3. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

4. UNIX for Dummies Questions & Answers

How to pick the latest file with date as one among the file name.( not exactly present date.)?

i have files like 1)20131112_abc_01.csv and 2)20131113_abc_01.csv and 3)20131113_abc_02.csv when i try to fetch the file in the next day. it shud pick the third file.. plz help me.. and i use `date +"%Y%m%d"` command to fetch..it fetches the current date... (2 Replies)
Discussion started by: applepie
2 Replies

5. Shell Programming and Scripting

Control - M Scheduler is not able to pick my shell script

Hi, Below is a shell script that i made:- #!/bin/ksh #path=/opt/tibco/shared/adaptadores/SSCC/EVEREST/input/ if ; then echo "ZIP Exists and now Processing" for files in /opt/tibco/shared/adaptadores/SSCC/EVEREST/input/T010B04.* do unzip $files echo "Files Unzipped" echo $files... (4 Replies)
Discussion started by: mmtrexon
4 Replies

6. Shell Programming and Scripting

Shell script to pick the oldest file

hi i need shell scrip to pick the oldest file... i.e i need a script to pick the oldest file I had input files in my input folder that are created on saturday,monday,tuesday .. i want a script such that first the script should pick saturday file ,then monday and then file created on... (5 Replies)
Discussion started by: hemanthsaikumar
5 Replies

7. Shell Programming and Scripting

Pick out the various extension file from log of the same date

extension file from log (3 Replies)
Discussion started by: NehaKrish
3 Replies

8. UNIX for Dummies Questions & Answers

unix script that will pick up first 10 file

Suppose I have a unix file which contain a lost of 60 files like filename1 filename2 ... .. ... filename60 I want to write a unix script that will pick up first 10 files in first run 10-20 files in 2 run 20-30 files in 3 run 30-40 files in 4 run 40-50 files in 5 run 50-60 files in 6... (1 Reply)
Discussion started by: er_zeeshan05
1 Replies

9. Shell Programming and Scripting

Script to pick out files from a file which are older than 15 days

Hi , I have a file abc.txt which actually contains a directory and file list -rwxrwxr-x 1 dmadmin mmasapp 334 Dec 03 2001 aafs_006.ksh -rwxrwxr-x 1 dmadmin mmasapp 1270 Nov 13 2001 mcl_deposit_ftp.ksh -rwxrwxr-x 1 dmadmin mmasapp 925 Oct 31 2001 ... (1 Reply)
Discussion started by: viv1
1 Replies

10. Shell Programming and Scripting

Sort files by Date-timestamps available in filename & pick the sortedfiles one by one

Hi, I am new to Unix shell scripting. Can you please help me with this immediate requirement to code.. The requirement is as given below. In a directory say Y, I have files like this. PP_100000_28062006_122731_746.dat PP_100000_28062006_122731_745.dat PP_100000_28062006_122734_745.dat... (4 Replies)
Discussion started by: Chindhu
4 Replies
Login or Register to Ask a Question