multiple condition matching and doing some predefined work


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting multiple condition matching and doing some predefined work
# 1  
Old 02-01-2012
multiple condition matching and doing some predefined work

Hi everybody,

I had 10 files in in one folder(/home/sai/) namely sai.
1.gz,2.gz,3.gz ..,10.gz.

I want to delete the files which are there home based on the following conditions

fliecount in sai folder==10 && grep -cv ".gz"==0

How to check this using awk?

Otherwise please suggest a best method for doing it?
# 2  
Old 02-01-2012
From where you want to delete the files?
From which files you want to grep ".gz"? I guess its file names and not the contents.

Please rephrase your requirement and give us more details with the clear example.
# 3  
Old 02-01-2012
Hi anchal,

I had 5 files in in one folder(/home/sai/) namely sai.
Code:
>cd /home/sai
>ls
1.gz 2.gz 3.gz 4.gz 5.gz

I want to delete the files which are there in home directory, if filecount in sai directory is 5 and also all files should be in *.gz format.
Code:
>pwd
/home/sai

'ls | wc -l`==5 && `ls | grep -cv ".gz"`==0

How to check this using awk?

Otherwise please suggest a best method for doing it?

Last edited by Franklin52; 02-01-2012 at 07:59 AM.. Reason: Please use code tags for code and data samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with tag value extraction from xml file based on a matching condition

Hi , I have a situation where I need to search an xml file for the presence of a tag <FollowOnFrom> and also , presence of partial part of the following tag <ContractRequest _LoadId and if these 2 exist ,then extract the value from the following tag <_LocalId> which is "CW2094139". There... (2 Replies)
Discussion started by: paul1234
2 Replies

2. Shell Programming and Scripting

Help with XML tag value extraction based on matching condition

sample xml file part <DocumentMinorVersion>0</DocumentMinorVersion> <DocumentVersion>1</DocumentVersion> <EffectiveDate>2017-05-30T00:00:00Z</EffectiveDate> <FollowOnFrom> <ContractRequest _LoadId="export_AJ6iAFoh6g0rE9"> <_LocalId>CRW2218451</_LocalId> ... (4 Replies)
Discussion started by: paul1234
4 Replies

3. Shell Programming and Scripting

If condition matching with special chars

Hi, I have file #cat drivers.txt fcs0 fcs1 vscsi1 vscsi2 In this i need to check the availabality of "fcs" or "vscsi" alone not vscsi0,fcs1 I tried with "if condition" but it is not working. cat drivers.txt| while read ADAP do echo "Checking for $ADAP" if ;then echo "FC... (9 Replies)
Discussion started by: ksgnathan
9 Replies

4. Shell Programming and Scripting

Help with File processing - Adding predefined text to particular record based on condition

I am generating a output: Name Count_1 Count_2 abc 12 12 def 15 14 ghi 16 16 jkl 18 18 mno 7 5 I am sending the output in html email, I want to add the code: <font color="red"> NAME COLUMN record </font> for the Name... (8 Replies)
Discussion started by: karumudi7
8 Replies

5. Shell Programming and Scripting

matching patterns inside a condition in awk

I have the following in an awk script. I want to do them on condition that: fext == "xt" FNR == NR { />/ && idx = ++i $2 || val = $1 next } FNR in idx { v = val] } { !/>/ && srdist = abs($1 - v) } />/ || NF == 2 && srdist < dsrmx {... (1 Reply)
Discussion started by: kristinu
1 Replies

6. UNIX for Dummies Questions & Answers

csh, pattern matching in if() condition.

Hi: I am struggling to get the simplest pattern matching to work, in csh. In this line: if ("$MY" =~ /my/) echo match it seems that I just can not make it to match, even when $MY is "mymymy". Thanks. N.B Phil ---------- Post updated at 11:23 PM ---------- Previous update... (0 Replies)
Discussion started by: phil518
0 Replies

7. Shell Programming and Scripting

multiple condition in if

All, My environment is Red Hat Enterprise Linux 5. I am using the following condition -- if -0 ] above command is not working. It is telling that -a unexpected. Please help me (10 Replies)
Discussion started by: user7509
10 Replies

8. Shell Programming and Scripting

if condition doesn't work

i want to get the value for column 4rth when i =4. please guide what i am doing wrong. thanks var=`cat file.csv` for i in $var; do { if ; then var4=$var4+$i fi echo $i } done I am geting this error message "0403-009 The specified number is not valid for this command." (8 Replies)
Discussion started by: sagii
8 Replies

9. UNIX for Dummies Questions & Answers

bash pattern matching echo *[! '/' ] doesn't work

without using ls, just using echo so purely pattern matching I can say echo */ <-- lists directories but how would I match files? surely something like *!/ or * but neither work ? it seems like there isn't much that I can put in but surely i should be able to put any ascii... (1 Reply)
Discussion started by: james hanley
1 Replies

10. Shell Programming and Scripting

Pattern-Matching in If-Condition

Hey Guys, I'm fighting with a particular pattern match today (ksh)... I need your help! Middle in my script I read a variable A's value. This value could have three differents form: 1) the NumClicks is the number of clicks user makes during session. 2) the MeanRate is the average number of... (6 Replies)
Discussion started by: jzillan
6 Replies
Login or Register to Ask a Question