Sponsored Content
Top Forums Shell Programming and Scripting Ignore Folder in Shell Script ? Post 302839769 by pasc on Friday 2nd of August 2013 04:33:21 PM
Old 08-02-2013
Ignore Folder in Shell Script ?

Hi,

I currently use a script to extract *.deb files located in a Directory called
"/var/mobile/Media/Downloads"
The Problem is howver I want the script to ignore the folder:
"/var/mobile/Media/Downloads/New Debs and Files"
(it shall NOT decompile any of the files in that folder.

Here is the script I have so far (which decompiles said files in the "New Debs and Files" Folder aswell):


Code:
sudo chmod -R 777 /var/mobile/Media/Downloads
sudo chown -R mobile:mobile /var/mobile/Media/Downloads
find /var/mobile/Media/Downloads/ -name "*.deb" | xargs -I {} dpkg -x {} {}.x
find /var/mobile/Media/Downloads/ -name "*.deb" | xargs -I {} dpkg -e {} {}.x/DEBIAN
sudo chmod -R 777 /var/mobile/Media/Downloads
sudo chown -R mobile:mobile /var/mobile/Media/Downloads
#######
# Remove .deb.x extension from any directory name
# DIR=/var/mobile/Media/Downloads
DIR=/var/mobile/Media/Downloads
echo Before:
file $DIR/*
for old_sub in $DIR/*.deb.x; do
  if [ -d "$old_sub" ]; then
    new_sub=$(echo "$old_sub" | sed "s/\.deb\.x$//")
    if [ -d "$new_sub" ]; then
      echo "$new_sub" already exists
      # take action, such as: rmdir "$new_sub"
      # take action, such as: rm -r "$new_sub"
      # take action, such as: exit
    fi
    mv "$old_sub" "$new_sub"
  fi
done
echo After:
file $DIR/*
ls -ld $DIR/*

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trick to ignore space in folder name

Hello All, I am getting error while passing a folder name that has space to the cmd line argument. sh log_delete2.sh "/home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A RM" log_delete2.sh: line 17: cd: /home/kumarpua/TESTARTIFACTS/atf-chix/ATF-subversion-dev/ssenglogs/A:... (3 Replies)
Discussion started by: pulkit
3 Replies

2. Shell Programming and Scripting

shell script for moving all the file from the same folder

Hi , I need a shell script which basicaly moves all the files from one folder say folder x to folder y and once they are moved to folder y a datetimestamp should be attached to there name for ex file a should be moved to y folder and renamed as a_20081015 (1 Reply)
Discussion started by: viv1
1 Replies

3. UNIX for Dummies Questions & Answers

Shell Script to Delete 1 folder and keep 5

I have situation that I had originally thought would be easily remedied until I learned more about how -mtime actually works. We have one server that collects backups from a number of other servers. The backup server is limited in space (for reasons that predate my employment). The standard... (4 Replies)
Discussion started by: greendevil
4 Replies

4. Shell Programming and Scripting

Shell Script to ignore # and take corresponding user and group

Hi, I have a following file: role.IMPACT_USER.user=admin role.IMPACT_USER.user=dd12345 role.IMPACT_USER.user=ss76767 #role.IMPACT_USER.user=root #role.IMPACT_USER.group=System role.IMPACT_USER.group=ImpactUser #Description: Allow users to login in to Impact, start and stop service... (5 Replies)
Discussion started by: dbashyam
5 Replies

5. UNIX for Dummies Questions & Answers

Shell script folder creation

hi can any one help me in shell scripting where in my requirement is to write a shell script where in if i run that script i should copy all the .doc files from one system to another systems within a network like from parent folders to child folder example parent folder A within parent folder... (5 Replies)
Discussion started by: afra
5 Replies

6. Shell Programming and Scripting

Ignore lines in Shell Script

Hi, I have a shell script, which reads a *.txt file - line by line. In this text file, I have some lines beginning with "#" that I want to ignore : MY_FILE #blah blah blah 1 blah blah blah 2 blah blah blah 3 #blah blah blah 4 I want my script to read only the following lines... (3 Replies)
Discussion started by: ad23
3 Replies

7. Shell Programming and Scripting

Shell script for FTP folder pattern

Hello, I have 3 folders on FTP server in the format yyyymmddhhmiss as below,ftp> cd /home/walgreens 250 CWD command successful ftp> ls 200 PORT command successful 150 Opening ASCII mode data connection for file list 20150708072901 20150708092901 20150708102901The above folders are in... (1 Reply)
Discussion started by: pavan_test
1 Replies

8. Shell Programming and Scripting

Shell script to copy files from on folder to another

I am trying to copy files with specific date and name to another folder. I am very new to shell scripting so i am finding it hard to do that. see the sample code i have written below. srcdir="/media/ubuntu/CA52057F5205720D/Users/st4r8_000/Desktop/office work/26 nov"... (13 Replies)
Discussion started by: Aqeel Abbas
13 Replies

9. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

10. UNIX for Beginners Questions & Answers

How to ignore mutiple strings when using shell script?

Hi All, I am trying to use below syntax to find ignore multiple locations while searching for a file. find / -name "$serviceitem" ! -size 0 2>&1 |egrep -v "tmp|docker|WinSxS|Permission|HISTORY|alternatives|bearer11ssl|manifest" I tried to assign all the ignore strings to one variable... (2 Replies)
Discussion started by: sravani25
2 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 03:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy