extract date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting extract date
# 1  
Old 09-12-2007
extract date

I run few command from c shell script and after this i want to check the status. I write the following code and it give the error message like "Variable Syntax". Here is my code:

#/ !/bin/csh -f

rm -f <filename>

if ($? != 0) then
echo " command does not executed successfully!"
end if

Pl. let me know where i am wrong?Smilie
# 2  
Old 09-12-2007
You are using $? - which is ksh (and sh).
Use $status.

And if ends with endif - not end [space] if
# 3  
Old 09-12-2007
hi

HI

refer to follow for help:

Code:
echo a
if [ $? -le 0 ]
then
echo "bb"
else
echo "cc"
fi

# 4  
Old 09-12-2007
Quote:
Originally Posted by summer_cherry
HI

refer to follow for help:

Code:
echo a
if [ $? -le 0 ]
then
echo "bb"
else
echo "cc"
fi

summer_cherry,
the question was asked in regards to the csh.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to extract date from a file?

Hello Gurus, I have one file from which I want to extract only dates. The below is the file format : ========================= Process ID 16842770 Log Read Checkpoint Oracle Integrated Redo Logs 2014-07-04 17:06:11 <=== SCN 1779.852353022 (7641599172606) Process ID ... (6 Replies)
Discussion started by: pokhraj_d
6 Replies

2. Shell Programming and Scripting

Extract date / time

How do i display in the below format without the brackets using shell script. Tue Oct 1 13:32:40 2013 Please use CODE tags not only for all code segments, input samples, and output samples. (7 Replies)
Discussion started by: ghosh_tanmoy
7 Replies

3. Shell Programming and Scripting

Extract week start,end date from given date in PERL

Hi All, what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case week start date will be-:12/19/2011... (2 Replies)
Discussion started by: parthmittal2007
2 Replies

4. Shell Programming and Scripting

How to extract date out of this filenames

I have filenames filenameA_fg_MMDDYY.tar.gz filenameASPQ_fg_MMDDYY.tar.gz filenameAFTOPHYYINGH_fg_MMDDYY.tar.gz filenameAGHYSW_fg_MMDDYY.tar.gz Is there a way I can extract the date out of these filenames? Thanks in advance (2 Replies)
Discussion started by: RubinPat
2 Replies

5. Shell Programming and Scripting

use metacharacters to extract date

If I have a filename as filename.txt.20090807 and I use for FILE in `find . -name "filename*" -type f` do my_time=${FILE#./filename.txt.} I get my output as 20090807 However if my filename is filename.Y20090807.txt Is there a way I can use metacharacters in my... (3 Replies)
Discussion started by: RubinPat
3 Replies

6. UNIX for Advanced & Expert Users

Extract Monday from given date

Hi I want to extract the date on Monday depending upon the user input for that week. For example if the input date is 20080528 then the output should be 20080526. If the input is 20080525 then it will be 20080519 i am working on IBM AIX Thanks (2 Replies)
Discussion started by: itsme_maverick
2 Replies

7. Shell Programming and Scripting

Extract Date from file

I am new to unix scripting. we are using bash. My task is I have dir which contains 30 files. The first column in each file is Date field. For all the files I need to extract the date part Ex(2007-09-05) from the file and add that at the end of that file. for example: The file names are... (2 Replies)
Discussion started by: magi
2 Replies
Login or Register to Ask a Question