The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Small Search script appu1987 Shell Programming and Scripting 2 06-03-2008 07:14 PM
Very small Shell Script Help... marconi Shell Programming and Scripting 2 12-11-2007 02:44 AM
small script everurs789 Shell Programming and Scripting 3 11-06-2007 02:08 PM
small script help rkl1 Shell Programming and Scripting 1 12-06-2005 08:26 PM
Need help in a small script super_duper_guy Shell Programming and Scripting 2 10-24-2005 07:06 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-18-2008
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
small script help

#!/bin/ksh

for i in *.log*
do

ls $i|sed 's/\.log$//g' | while read file
do
echo "file $file is Running" >> lls.txt
echo "***************">> lls.txt

done
done

------------------------------------------------------------------

the output is :

file AdapterCCProvisioningInterface is Running
**************************************************************************************************** *******
file AdapterCCProvisioningInterface.log.1 is Running
**************************************************************************************************** *******
file AdapterCCProvisioningInterface.log.2 is Running

---------------------------------------------------------------------

but i want only 1st kind of file as o/p.......it should not display .log or .log.1 or likewise
only filename before .log like in 1st..........

i have some 170 files like that.plz help me in this
Reply With Quote
Forum Sponsor
  #2  
Old 01-18-2008
Registered User
 

Join Date: Jun 2007
Posts: 115
modify your sed part like below

ls $i|sed 's/\.log*/\.log/g'

Quote:
Originally Posted by ali560045 View Post
#!/bin/ksh

for i in *.log*
do

ls $i|sed 's/\.log$//g' | while read file
do
echo "file $file is Running" >> lls.txt
echo "***************">> lls.txt

done
done

------------------------------------------------------------------

the output is :

file AdapterCCProvisioningInterface is Running
**************************************************************************************************** *******
file AdapterCCProvisioningInterface.log.1 is Running
**************************************************************************************************** *******
file AdapterCCProvisioningInterface.log.2 is Running

---------------------------------------------------------------------

but i want only 1st kind of file as o/p.......it should not display .log or .log.1 or likewise
only filename before .log like in 1st..........

i have some 170 files like that.plz help me in this
Reply With Quote
  #3  
Old 01-18-2008
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
now it is showing the o/p like this

file AdapterCCSendProvisioningGAP.log is Running
**************************************************************************************************** *******
file AdapterCCSendProvisioningGAP.log.1 is Running
**************************************************************************************************** *******
file AdapterCCSendProvisioningGAP.log.2 is Running
**************************************************************************************************** *******
file AdapterCCSendProvisioningGAP.log.3 is Running
----------------------------------------------------------------------

i just want file AdapterCCSendProvisioningGAP is Running and not .log or after .log
Reply With Quote
  #4  
Old 01-18-2008
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Quote:
Originally Posted by skyineyes View Post
modify your sed part like below

ls $i|sed 's/\.log*/\.log/g'
Code:
ls $i | sed "s/\.log*//g"
Reply With Quote
  #5  
Old 01-18-2008
Registered User
 

Join Date: Jun 2006
Posts: 74
try this...

ls $i | sed "s/\.log.*$//"
Reply With Quote
  #6  
Old 01-18-2008
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
this command

ls $i | sed "s/\.log.*$//"

gives the o/p as

AdapterCCSendProvisioningGAP
**************************************************************************************************** *******
AdapterCCSendProvisioningGAP
**************************************************************************************************** *******
AdapterCCSendProvisioningGAP
**************************************************************************************************** *******
AdapterCCSendProvisioningGAP
-----------------------------------------------------------------

but i want unique o/p.......how to make chages in this command so that it gives the same o/p but only one not repeted one
Reply With Quote
  #7  
Old 01-18-2008
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Quote:
Originally Posted by ali560045 View Post
this command

ls $i | sed "s/\.log.*$//"

gives the o/p as

AdapterCCSendProvisioningGAP
**************************************************************************************************** *******
AdapterCCSendProvisioningGAP
**************************************************************************************************** *******
AdapterCCSendProvisioningGAP
**************************************************************************************************** *******
AdapterCCSendProvisioningGAP
-----------------------------------------------------------------

but i want unique o/p.......how to make chages in this command so that it gives the same o/p but only one not repeted one
Code:
ls $i | sed "s/\.log.*$//" | sort -u
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:38 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0