Script to extract all deb files in a fldr to respective folderstructures


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to extract all deb files in a fldr to respective folderstructures
# 1  
Old 11-13-2011
Script to extract all deb files in a fldr to respective folderstructures

Hi, since half an hour I currently try to write a script that will:
1) Extract every debian file in a directory
2) Extracts it to a folder that matches the debians filename
3) Extracts it so the structure looks like that:

DEBIANFILENAME
|
-------------- DEBIAN
|
-------------- DEBIANDATA (Applications, whatever)

to achieve this I used that:
Code:
dpkg -x *.deb DEBIANFILENAME
dpkg -e *.deb DEBIANFILENAME
mv DEBIAN DEBIANFILENAME
sudo chmod -R 755 DEBIANFILENAME

however this doesn't:
- extract multiple debians
- only works with one debian a time
- doesn't create folders that match the previous debian filename

I would need it to read the filename of each debian as a variable, then feeding it into the script instead of DEBIANFILENAME, afterwards delete the just extracted .deb file.

I can't figure out how to do it... I tried different approaches, like
Code:
x='fname='basename $fname deb''

but most likley just Smilie don't get it.
# 2  
Old 11-13-2011
Code:
find /dir/ -name *.deb -exec dpkg -x {} /;


try this i havenot tried but just trying to help you
This User Gave Thanks to robo For This Post:
# 3  
Old 11-14-2011
Thanks for the answer !

However I get this upon executing your suggestion:

find: path must preceed expression
# 4  
Old 11-14-2011
Code:
find /dir/ -name "*.deb" -exec dpkg -x {} /;

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 5  
Old 11-14-2011
Quote:
Originally Posted by ahamed101
Code:
find /dir/ -name "*.deb" -exec dpkg -x {} /;

--ahamed
a little correction Smilie
Code:
find /dir/ -name "*.deb" -exec dpkg -x '{}' \;

These 2 Users Gave Thanks to ygemici For This Post:
# 6  
Old 11-15-2011
thanks !

It now says "dpkg needs a target"
Am I doing something wrong ?
# 7  
Old 11-15-2011
are you sure you are executing the same code ygemici gave you?...
Try this...
Code:
find /dir/ -name "*.deb" | xargs -I {} dpkg -x {} {}.x

--ahamed

PS: I am away from my unix box so the code is not tested!
This User Gave Thanks to ahamed101 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to pass the config file lines as variable on the respective called function on a script

I want to make a config file which contain all the paths. i want to read the config file line by line and pass as an argument on my below function. Replace all the path with reading config path line by line and pass in respective functions. how can i achieve that? Kindly guide. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

2. UNIX for Beginners Questions & Answers

How to write a UNIX script to send a mail to the respective individual users about their groups?

Hi Team, I got a requirement to send a mail to the individual users of a unix server about their respective groups. can some one help me to provide the script as I am unable to write that. I tried with below lines but I come out with errors. cat /etc/passwd | awk -F':' '{ print $1}' |... (6 Replies)
Discussion started by: harshabag
6 Replies

3. Shell Programming and Scripting

Copy files in respective directories

Hi Guys, I need to copy the files to respective directories based on name of the file. My script is something like below con=$1 for file in `cat $con` do file_tmp=$(ls -t1 $path| grep -i $file | head -n 1) echo $file_tmp if then cp $path$file_tmp $DIR/ap if then... (16 Replies)
Discussion started by: Master_Mind
16 Replies

4. Shell Programming and Scripting

> dpkg-deb to Extract and Reconstruct a Multipart Archive???

Greetings! Here's one which has been bugging me for a bit ;) As might be known, LibreOffice is available to some of us Linux folk as a large set of debs. Of course, being a curious sort, I'd like to dig in and recreate the original tree which is composed of these assorted archives. So, I... (1 Reply)
Discussion started by: LinQ
1 Replies

5. Shell Programming and Scripting

Script to extract/compare from two files.

I have two files : Alpha and Beta. The files are as follows (without arrow marks.) Alpha: A 1 D 90 G 11 B 24 C 15 Beta: B 24 C 0 <-- G 11 D 20 <-- A 4 <-- E 777 <-- Expected output of the script : Alpha: (2 Replies)
Discussion started by: linuxadmin
2 Replies

6. Shell Programming and Scripting

need a shell script to extract the files from source file and check whether those files existonserve

Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Discussion started by: muraliinfy04
13 Replies

7. UNIX for Dummies Questions & Answers

rename files based on their respective directory name

I have a number of files in directories labeled like this: /Data/tr_gray/tr_DTI/dti_FA.nii.gz (the brackets here represent a range of number that the files are labeled with) I need to rename each dti_FA.nii.gz file according to the name of the folder it resides in. For example, the file ... (3 Replies)
Discussion started by: tk0034
3 Replies

8. Shell Programming and Scripting

Find all .htaccess files and make a backup copy in respective directories

Hey guys, I need to know how to locate all .htaccess files on the server and make a backup of them in the folder they reside before I run a script to modify all of them. So basically taking dir1/.htaccess and copying it as dir1/.htaccess_bk dir2/.htaccess copying as dir2/.htaccess_bk... (5 Replies)
Discussion started by: boxx
5 Replies

9. Shell Programming and Scripting

A shell script for create a a file in the respective path

Hello forum members, I have to create a out file in the current path./aaa/bbb/ccc/hhh. i am writing script below. ###script Begins##### #!/bin/ksh echo "Weclome" if then echo "Hello" rm -rf $aaa/bbb/ccc/hhh #clean the exsisting o/p file echo "no... (2 Replies)
Discussion started by: rajkumar_g
2 Replies

10. Shell Programming and Scripting

Moving files to their respective subdirectories

Hello, I have files like this img.txt ./Rearrange_zoca/fitted_data/WX226_05b_Ncere.jpg ./Rearrange_zoca/fitted_data/w322_03B_60_70.jpg ./Rearrange_zoca/fitted_data/wrx226_12A_50_60.jpg ./Rearrange_zoca/fitted_data/wx124_01A_50_60.jpg ./Rearrange_zoca/fitted_data/wx124_02A_50_60.jpg... (3 Replies)
Discussion started by: avatar_007
3 Replies
Login or Register to Ask a Question