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
Debugging PL/SQL from .NET iBot Oracle Updates (RSS) 0 04-06-2008 05:10 AM
Debugging the JVM Using dbx iBot UNIX and Linux RSS News 0 03-06-2008 07:20 PM
Nee help debugging script..plz gzs553 Shell Programming and Scripting 8 11-24-2006 11:21 AM
Regarding Debugging sarwan Shell Programming and Scripting 2 02-09-2006 12:32 PM
how to run debugging on c program ibeg High Level Programming 3 08-12-2002 02:20 PM

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 11-27-2006
oandarilho01 oandarilho01 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 2
Debugging the code

Greetings..
I'm trying to build a script to manage my Mugen's chars, adding the chars to the game, searching the chars dir for .zip and .rar files, and then listing the nemes before the dots "." to a separate file in /tmp, and then create the folders for each file, copying the compacted files to their respective folders, and then uncompressing them there.
So, well, I'm getting some erros. The script does not work with some files, but try to do the same thing two times with others.

Well, this is the environment:
Code:
-rwxr-xr-x 1 oandarilho01 users  416 2006-11-27 01:31 adiciona_char.sh
-rw-r--r-- 1 oandarilho01 users 6,2M 2006-11-02 00:19 joker.rar
drwxr-xr-x 2 oandarilho01 users  496 2002-04-21 01:53 kfm
-rw-r--r-- 1 oandarilho01 users 1,1M 2006-11-02 07:51 kiriko.zip
-rw-r--r-- 1 oandarilho01 users 3,7M 2006-10-24 00:24 kyle.zip
-rw-r--r-- 1 oandarilho01 users 3,5M 2006-11-02 00:24 ngbc_ai.rar
-rw-r--r-- 1 oandarilho01 users 3,4M 2006-11-02 07:48 ngbc_fuuma.rar
-rw-r--r-- 1 oandarilho01 users 4,2M 2006-11-02 07:48 ngbc_kisarah.rar
-rw-r--r-- 1 oandarilho01 users 2,4M 2006-10-24 00:00 oni.zip
-rw-r--r-- 1 oandarilho01 users 4,3M 2006-11-02 00:12 Oswald_XI.zip
-rw-r--r-- 1 oandarilho01 users 1,6M 2006-11-02 00:10 rai-EX.rar
-rw-r--r-- 1 oandarilho01 users  101 2002-04-21 00:45 readme.txt
-rw-r--r-- 1 oandarilho01 users 6,7M 2006-10-24 00:24 rimle.zip
-rw-r--r-- 1 oandarilho01 users 627K 2006-11-02 07:51 shampoo.zip
-rw-r--r-- 1 oandarilho01 users 1,1M 2006-10-24 00:03 tetsuo_advance.zip
-rw-r--r-- 1 oandarilho01 users 5,1M 2006-11-02 00:18 xi_elisabeth.rar
-rw-r--r-- 1 oandarilho01 users 5,4M 2006-11-02 00:27 xi_jenet.rar
And this is the script:
Code:
#!/bin/bash
# Script para ajuste de Mugen - v0.01
#
# Definindo as variáveis de ambiente:
CHARDIR=`pwd`

# Criando pasta para o char
ls -l *.zip *.rar $CHARDIR | awk -F" " '{ print $8 }' | awk -F"." '{ print $1 }' > /tmp/novos
for char in `cat /tmp/novos`; do
   mkdir $CHARDIR/$char
   cp $char.zip $CHARDIR/$char
   cd $CHARDIR/$char
   unzip $char.zip
   cd ..
done
rm /tmp/novos
Even either don't knowing or don't linking Mugen, I believe some of you could help me to improve this code..
So, I thank you all for the attention and help.
  #2 (permalink)  
Old 11-27-2006
nathan nathan is offline VIP Member  
Supporter
  
 

Join Date: Jul 2006
Posts: 156
Does your version of unzip have the -d option? ( man unzip )
Code:
       [-d exdir]
              An  optional directory to which to extract files.  By default, all files and
              subdirectories are recreated in the current directory; the -d option  allows
              extraction  in an arbitrary directory (always assuming one has permission to
              write to the directory).

If so, then something like this might work (only tested with .zip files):
Code:
#! /bin/bash

for X in `ls *.zip *.rar` ; do
  DIR=`echo $X | sed -e "s/^\(.*\)\.\(zip\|rar\)$/\1/g"`
  unzip $X -d $DIR
done
  #3 (permalink)  
Old 11-27-2006
oandarilho01 oandarilho01 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 2
Whow... it sounds really cool.. thanks..
I`ll try it as soon as possible!
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 08:52 PM.


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