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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Executing a shell script from windows;script present in unix rajneesh_kapoor UNIX for Advanced & Expert Users 4 05-08-2009 03:54 PM
(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script praka Shell Programming and Scripting 6 04-15-2009 07:09 AM
need inputs on how i can change my script to reduce amount of time the script takes madhul2002 Shell Programming and Scripting 1 04-01-2009 08:40 PM
create a shell script that calls another script and and an awk script magikminox Shell Programming and Scripting 0 06-26-2008 03:50 AM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 04: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 06-08-2009
d4n3lu d4n3lu is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 10
script help

I ahve wrote this script is renaming and moving some files to a specific directory. The script works but the way I have defined good it takes more then the 2 files I need. The issue is in bold. How can I take the other 2 out? Your help is really apreciated...


Code:
#!/bin/ksh
######################################################
#
#  By Dan Munteanu
#  Description: The script will process the 2 weekly
#  chrysler files RJE26726.090502122225.#CSGI907.Z
#  and RJE26726.090502122225.#CSGI808.Z
#
######################################################
#output path
output_path=/u/rjeadmin/dan/rerun3770
# select chry3770/unknown directory so the compressed file can be uncompressed
dir_chry=/u/rjeadmin/dan/chry3770/unknown
cd ${dir_chry}
#file maniputations
good=$(ls | grep CSGI[98]0[87]\.Z | grep -v CSG908 | grep -v CSG807)
for file in ${good}
 do
   seg1=$(echo ${file} | cut -f1 -d.)
   seg2=$(echo ${file} | cut -f2 -d.)
   seg3=$(echo ${file} | cut -f3 -d.)
   newseg3=$(echo ${seg3} | sed "s/\#//" | sed "s/$/Z/")
   oldfile=${seg1}.${seg2}.${seg3}
   newfile=${seg1}.${seg2}.${newseg3}
   uncompress ${file}
   mv ${oldfile} ${output_path}/${newseg3}/${newfile}
   Rc=$?
    if [ "$Rc" -ne 0 ]; then
     echo "Move failed."
    fi
 done

  #2 (permalink)  
Old 06-08-2009
anchal_khare anchal_khare is online now
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
not sure about the problem. but..
do you want remove the "grep -v"??

try "grep -w" for exact pattern match.
  #3 (permalink)  
Old 06-08-2009
d4n3lu d4n3lu is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 10
the think is that I am getting CSGI[98]0[87] which is CSGI908, 907, 808 and 807 only need the 907 and 808 do you know a good way to do this? Maybe a better way

-----Post Update-----

Problem solved it was a typo

-----Post Update-----

Problem solved it was a typo
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 07:49 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