Please help me to figure out the logic for this problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help me to figure out the logic for this problem
# 8  
Old 02-05-2010
Quote:
Originally Posted by Franklin52
Sorry, I forgot a closing brace. I've edited the code.
thanks , but

i am receving again something i think i am not suppose to.

Code:
[oracle@dell backupset]$ ls -l | sort -r | awk -F[./] 'NR==1{next} /^d/{a[$NF];next} !($(NF-1) in a){system("ls " $(NF-1)"."$NF)}'
ls: invalid line width: -r--r--
ls: invalid line width: -r--r--
ls: invalid line width: -r--r--
ls: invalid line width: -r--r--
ls: invalid line width: -r--r--
[oracle@dell backupset]$



---------- Post updated at 12:51 PM ---------- Previous update was at 12:49 PM ----------

/code]

---------- Post updated at 12:49 PM ---------- Previous update was at 12:44 PM ----------

Quote:
Originally Posted by cmf1985
This will work also (obviously not as short written as Franklin52's solution):

hello, thanks , but i am getting something wierd...
i just wanted some script that could check if some file exists and direcory with the same name but without the .extension part and then if exists , to delete this kind of files.
i tryied your solution but no luck , maybe i am doing something worng :


[code]
[oracle@dell backupset]$ TARGET=/u02/oradata/arch/flash/RING10/backupset/
[oracle@dell backupset]$ TEMP=/u02/oradata/arch/flash/RING10/backupset/temp.tmp

[oracle@dell backupset]$ ls -l $TARGET | grep ^d | awk '{print $8}' > $TEMP
[oracle@dell backupset]$ ls $TARGET | grep -v -f $TEMP | awk -v TARGET="$TARGET" '{print TARGET$0}' | xargs ls -lrta
-rw-r--r-- 1 oracle oinstall 6407 Jan 29 07:15 /u02/oradata/arch/flash/RING10/backupset/2010_01_29.log
-rw-r--r-- 1 oracle oinstall 4102 Feb 2 07:15 /u02/oradata/arch/flash/RING10/backupset/2010_02_02.log
-rw-r--r-- 1 oracle oinstall 3923 Feb 3 07:15 /u02/oradata/arch/flash/RING10/backupset/2010_02_03.log
-rw-r--r-- 1 oracle oinstall 4667 Feb 4 14:02 /u02/oradata/arch/flash/RING10/backupset/2010_02_04.log
-rw-r--r-- 1 oracle oinstall 5177 Feb 5 07:14 /u02/oradata/arch/flash/RING10/backupset/2010_02_05.log
-rw-r--r-- 1 oracle oinstall 18 Feb 5 09:03 /u02/oradata/arch/flash/RING10/backupset/temp.tmp

/u02/oradata/arch/flash/RING10/backupset/2010_02_05:
total 1174348
-rw-r----- 1 oracle oinstall 38751744 Feb 5 07:00 o1_mf_annnn_TAG20100205T070010_5pqdzd6r_.bkp
-rw-r----- 1 oracle oinstall 1161453568 Feb 5 07:13 o1_mf_nnndf_TAG20100205T070027_5pqdzw0r_.bkp
drwxr-x--- 2 oracle oinstall 4096 Feb 5 07:13 .
-rw-r----- 1 oracle oinstall 1128448 Feb 5 07:13 o1_mf_annnn_TAG20100205T071353_5pqfs2yb_.bkp
drwxr-x--- 5 oracle oinstall 4096 Feb 5 09:02 ..

/u02/oradata/arch/flash/RING10/backupset/2010_02_04:
total 2285344
-rw-r----- 1 oracle oinstall 1162616832 Feb 4 07:13 o1_mf_nnndf_TAG20100204T070029_5pnrmxpp_.bkp
-rw-r----- 1 oracle oinstall 1153536 Feb 4 07:13 o1_mf_annnn_TAG20100204T071355_5pnsf51k_.bkp
-rw-r----- 1 oracle oinstall 9914880 Feb 4 13:46 o1_mf_annnn_TAG20100204T134643_5pojfo2k_.bkp
-rw-r----- 1 oracle oinstall 1162960896 Feb 4 14:01 o1_mf_nnndf_TAG20100204T134648_5pojfrlt_.bkp
-rw-r----- 1 oracle oinstall 1224704 Feb 4 14:01 o1_mf_annnn_TAG20100204T140154_5pokb3k8_.bkp
drwxr-x--- 2 oracle oinstall 4096 Feb 5 07:14 .
drwxr-x--- 5 oracle oinstall 4096 Feb 5 09:02 ..

/u02/oradata/arch/flash/RING10/backupset/2010_02_03:
total 8
drwxr-x--- 2 oracle oinstall 4096 Feb 5 07:14 .
drwxr-x--- 5 oracle oinstall 4096 Feb 5 09:02 ..
[oracle@dell backupset]$ cat temp.tmp
07:14
07:14
07:13
[oracle@dell backupset]$
[/code ]
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with change significant figure to normal figure command

Hi, Below is my input file: Long list of significant figure 1.757E-4 7.51E-3 5.634E-5 . . . Desired output file: 0.0001757 0.00751 0.00005634 . . . (10 Replies)
Discussion started by: perl_beginner
10 Replies

2. Shell Programming and Scripting

Nawk if logic problem

nawk '{ fmt="%3s %22s %48s %35s %21s\n"; if ($3==$6 && $1=="STOPLOSS") { tpy="Successful Match"; jnme=$1; sts="File will be loaded"; cntrl=$3; audit=$6; printf (fmt, tpy,jnme,sts,cntrl,audit) >> "'${AUDIT_DATA_FILE}/${AUDIT36}'" }else if ($3!=$6 && $1=="STOPLOSS") { tpy="Mis-Match ";... (4 Replies)
Discussion started by: wawa
4 Replies

3. UNIX for Dummies Questions & Answers

if then else logic with while loop problem

Hi Friends, I have to do write a shell file based on one flag.If that flag value is 'N' then process look in $DATA are and the normal process continue.If vaule is 'P' then it check for the files in different location $CONV and move those file in $DATA area and rest of the process... (2 Replies)
Discussion started by: Param0073
2 Replies

4. Shell Programming and Scripting

Problem with if logic

Hi there, In my shell program I have two if statements the first one checks that the date in yyyymm format is equal to a date from the parameter file in yyyymm format, and that the file and sends an appropiate email The second one checks that the date in yyyymm format is equal to a... (1 Reply)
Discussion started by: rjsha1
1 Replies
Login or Register to Ask a Question