Sponsored Content
Top Forums Shell Programming and Scripting Ignore Folder in Shell Script ? Post 302839785 by pasc on Friday 2nd of August 2013 05:20:59 PM
Old 08-02-2013
Sadly it still extracts the debs in the Subfolder.

Maybe the solution would be to *only* extract the files inside the Downloads folder completly ignoring any subfolders there might be ?

If there is no solution to this I might aswell temporarily move the folder out of the way, but that is onyl my last resort.

Thanks.


EDIT:

Ha! that is too funny, even when I change my code to hamper with the permissions/and or move the folder away for the time the extracting takes place and move it back right after/rechange the permissions it STILL hampers with the debs in the sub dir:

Code:
sudo chmod -R 777 /var/mobile/Media/Downloads
sudo chown -R mobile:mobile /var/mobile/Media/Downloads

#sudo mv "/var/mobile/Media/Downloads/New Debs and Files" /var/mobile/Media/
sudo chmod -R 000 "/var/mobile/Media/Downloads/New Debs and Files"
sudo chown -R wheel:wheel "/var/mobile"Media/Downloads"New Debs and Files"

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/*
clear

#mv "/var/mobile/Media/New Debs and Files" "/var/mobile/Media/
sudo chmod -R 777 "/var/mobile/Media/Downloads/New Debs and Files"
sudo chown -R mobile:mobile "/var/mobile"Media/Downloads"New Debs


Last edited by pasc; 08-02-2013 at 08:18 PM.. Reason: Added new Approach
 

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
GSMPB(8)						      System Manager's Manual							  GSMPB(8)

NAME
gsmpb - GSM mobile phone phonebook manipulation program SYNOPSIS
gsmpb [ -b baudrate ] [ --baudrate baudrate ] [ -c ] [ --copy ] [ -d destination device or file ] [ --destination destination device or file ] [ -h ] [ --help ] [ -i ] [ --index ] [ -I init string ] [ --init init string ] [ -p phonebook name ] [ --phonebook phonebook name ] [ -s source device or file ] [ --source source device or file ] [ -t character set ] [ --charset character set ] [ -v ] [ --version ] [ -V ] [ --verbose ] [ -X ] [ --xonxoff ] [ -y ] [ --synchronize ] DESCRIPTION
gsmpb can store or retrieve phonebook entries residing in a GSM mobile phone's phonebook to or from a file. A synchronization mode is also available. gsmpb reads entries from the source which can be a mobile phone (if a serial device file is given) or a file (if a file name is given). The source is never modified. gsmpb writes phonebook entries to a destination file or device. Depending on the mode the source is copied to the destination file, thus overwriting the destination, or the destination is synchronized with regard to the source which is the default (details see below). If "-" is given as the parameter for the --source or --destination options, the phonebook is read from standard input and/or written to standard output, respectively. Phonebook entries names are encoded using the GSM default alphabet in the mobile phone, whereas they are stored using the Latin-1 encoding in phonebook files. When reading phonebook entries from a mobile phone entry names are converted from the GSM default to Latin-1. Charac- ters that can not be converted to Latin-1 are encoded as character code 172 (Latin-1 boolean "not"). When writing file-based phonebook entries to a mobile phone a conversion to the GSM default alphabet takes place. Characters that can not be converted are encoded as GSM delta (code 16). If the default character set has been changed using the --charset option no conversion takes place. Error messages are printed to the standard error output. If the program terminates on error the error code 1 is returned. OPTIONS
-b baudrate, --baudrate baudrate The baud rate to use. The default baudrate is 38400. -c, --copy This causes the contents of the source to be copied to the destination. After this operation the destination has exactly the same contents as the source. -d destination, --destination destination The destination device or file. -h, --help Prints an option summary. -I init string, --init init string Initialization string to send to the TA (default: "E0"). Note that the sequence "ATZ" is sent first. -i, --index If the index position is given, gsmpb preserves the assignment of entries to memory slots in the mobile phone's phonebook. This can be used to backup phonebook entries with their position into a phonebook file or to change the position of entries by editing a phonebook file and writing them back to the mobile phone. If this option is given the phonebook file used as the source must con- tain indices for every entry. Additionally, these indices must be unique, ie. it is not allowed to assign one entry twice to a spe- cific position in the mobile phone's phonebook. -p phonebook, --phonebook phonebook The name of the phonebook to read from or write to. This is only used for device sources and destinations. Commonly available phone- books are: FD SIM fixdialling-phonebook LD SIM last-dialling-phonebook ME ME phonebook MT combined ME and SIM phonebook SM SIM phonebook TA TA phonebook -s source, --source source The source device or file. -t character set, --charset character set Set the character set to use for phonebook operations (default is the GSM default alphabet). -v, --version Prints the program version. -V, --verbose Prints out a detailed progress report. -X, --xonxoff Uses software handshaking (XON/XOFF) for accessing the device. -y, --synchronize This causes the contents of the source to be synchronized with the destination (default). Synchronization in this con- text means: - If the source contains an entry with a name that does not exist in the destination this entry is added to the desti- nation. - If the source contains an entry with a name that can also be found in the destination, the entry in the destination is overwritten (ie. the telephone number is updated). Exception: More then one entry with the name exists in the destination. In this case the new entry ist just added. - Entries in the destination that do not exist in the source are deleted. Note that synchronization has the following properties that differ from copying: This algorithm does not change the location of unchanged entries in the destination phonebook. The synchronization function is not case-sensitive when comparing names. PHONEBOOK FILE FORMAT
Phonebook entries are stored in phonebook files that are meant to be human-readable and -editable. There is one phonebook entry per line, and each line has the format: index|text|phone number The fields have the following meanings: index The index of the entry which must be a positive number. The index may also be empty. Indices can be used in conjunction with the --index option to store the entry into a specific position in the mobile phone. text Descriptive text for the entry. The text may con- tain the special characters '', '|', carriage return (ASCII code 13), or line feed (ASCII code 10). These must be written "\", "|", " ", " ", respectively. The text should only contain charac- ters that can be encoded using the GSM default alphabet (see comments above). phone number Phone numbers can only contains the digits 0-9 and the '+' sign. A '+' sign denotes an international number. EXAMPLES
The following invocation of gsmpb synchronizes the mobile phone's SIM phonebook with the file $HOME/.phonebook: gsmpb --synchronize -b 19200 -d /dev/mobilephone -s $HOME/.phonebook -p "SM" AUTHOR
Peter Hofmann <software@pxh.de> BUGS
Report bugs to software@pxh.de. Include a complete, self- contained example that will allow the bug to be repro- duced, and say which version of gsmpb you are using. COPYRIGHT
Copyright (C) 1999 Peter Hofmann gsmpb is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Pub- lic License as published by the Free Software Foundation; either version 2, or (at your option) any later version. gsmpb is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied war- ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with gsmpb; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. SEE ALSO
gsminfo(7), gsmctl(1), gsmsendsms(1), gsmsmsd(8), gsmsms- store(1). gsmpb v1.10 Sat Jun 16 22:10:00 UTC 2012 GSMPB(8)
All times are GMT -4. The time now is 03:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy