The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 10:14 PM
Very small Shell Script Help... marconi Shell Programming and Scripting 2 12-11-2007 05:44 AM
small script everurs789 Shell Programming and Scripting 3 11-06-2007 05:08 PM
small script help rkl1 Shell Programming and Scripting 1 12-06-2005 11:26 PM
Need help in a small script super_duper_guy Shell Programming and Scripting 2 10-24-2005 10:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-18-2008
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
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
  #2 (permalink)  
Old 01-18-2008
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
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
  #3 (permalink)  
Old 01-18-2008
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
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
  #4 (permalink)  
Old 01-18-2008
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
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"
  #5 (permalink)  
Old 01-18-2008
quintet quintet is offline
Registered User
  
 

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

ls $i | sed "s/\.log.*$//"
  #6 (permalink)  
Old 01-18-2008
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
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
  #7 (permalink)  
Old 01-18-2008
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0