I have a question for you, I'm trying to create a script that will automate creating loading screens for the iPhone.
So what I need to do, is list the directories inside /var/mobile/Applications and scan inside those, for the .app directory inside each. Take that .app name and create a folder in /var/stash/Themes/LoadingScreens.theme/Folders with the same name found earlier.
I tried to get the list with this command:
But what I get is a list with the full path in front of what I need to get. How could I either truncate it to keep only what I need, or either list only the .app directories, and not the full path preceding it?
what does this command do ? as in
does this command just make sure everything in the file is executed?
or does it flush the file?
Actually this is used on a file in a progress database but I believe it is a unix command? (2 Replies)
Hello everybody it's me again.
I have a procces that is writing in a 'file1' automatically but i want to truncate 'file1' to a filesize 'x' that mean if the 'file1' size is 'x' i want to delete the first lines while the last lines are being writed, that have sence?
in the process are an... (1 Reply)
Is it possibe to use sed for the following? I would like to truncate the output of a directory path if it's over 3 directory levels deep. For example:
/dir1/dir2/dir3 -- NO change required
but,
/dir1/dir2/dir3/dir4 would output as ~/dir4
Thanks. (4 Replies)
I have one file which first line is blank and second line has some data.
$cat filename
output:
30-MAY-07
I want to store 30-MAY-07 value in one variable.
for that I wrote
var="`head -2 filename`"
It will give that result but I want to truncate the first line which is blank.
plz help. (2 Replies)
Hi
In unix able to connect to oracle database and create table ,when rerun ,if table exist ,truncate that table.Any idea how to do that
a.sh
----
sqlplus -s datadmin/password <<EOF
create table xx(col1 number,
col2...
);
exit;
EOF
I... (1 Reply)
Hello,
Given below are 2 sample paths from 2 different servers:
/opt/temp/PROD/Script/New/Letters
/opt/Share/temp/Share1/PROD/Script/Files/New/Letters
I would like to truncate the path till the folder "PROD". Please note that the field count of the folder "PROD" vaires from... (1 Reply)
Hi All
I've googled around for this and can't see a way of doing it.
I have a file that contains a number of records that are layed out something like the following.
/path/to/directory/that/contains/a/file/I/need/filename.pdf
The path itself can vary both in terms of the names and the... (7 Replies)
hi,
i have a directory at /path/unix with the following files
1.txt
2.txt
3.txt
4.txt
I want to make another file called filenames.txt at a different location called /path/home. So, my output file would be
/path/home/filenames.txt with contents
/path/unix/1.txt... (1 Reply)
Currently I am using this laborious command
lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}'
Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies
LEARN ABOUT NETBSD
getopt
GETOPT(1) BSD General Commands Manual GETOPT(1)NAME
getopt -- parse command options
SYNOPSIS
args=`getopt optstring $*`
set -- `getopt optstring $*`
DESCRIPTION
getopt is used to break up options in command lines for easy parsing by shell procedures, and to check for legal options. [Optstring] is a
string of recognized option letters (see getopt(3)); if a letter is followed by a colon, the option is expected to have an argument which may
or may not be separated from it by white space. The special option ``--'' is used to delimit the end of the options. getopt will place
``--'' in the arguments at the end of the options, or recognize it if used explicitly. The shell arguments ($1, $2, ...) are reset so that
each option is preceded by a ``-'' and in its own shell argument; each option argument is also in its own shell argument.
getopt should not be used in new scripts; use the shell builtin getopts instead.
EXAMPLES
The following code fragment shows how one might process the arguments for a command that can take the options [a] and [b], and the option
[c], which requires an argument.
args=`getopt abc: $*`
if [ $? -ne 0 ]; then
echo 'Usage: ...'
exit 2
fi
set -- $args
while [ $# -gt 0 ]; do
case "$1" in
-a|-b)
flag=$1
;;
-c)
carg=$2; shift
;;
--)
shift; break
;;
esac
shift
done
This code will accept any of the following as equivalent:
cmd -acarg file file
cmd -a -c arg file file
cmd -carg -a file file
cmd -a -carg -- file file
IEEE Std 1003.2 (``POSIX.2'') mandates that the sh(1) set command return the value of 0 for the exit status. Therefore, the exit status of
the getopt command is lost when getopt and the sh(1) set command are used on the same line. The example given is one way to detect errors
found by getopt.
DIAGNOSTICS
getopt prints an error message on the standard error output when it encounters an option letter not included in [optstring].
SEE ALSO sh(1), getopt(3)HISTORY
Written by Henry Spencer, working from a Bell Labs manual page. Behavior believed identical to the Bell version.
BUGS
Whatever getopt(3) has.
Arguments containing white space or embedded shell metacharacters generally will not survive intact; this looks easy to fix but isn't.
The error message for an invalid option is identified as coming from getopt rather than from the shell procedure containing the invocation of
getopt; this again is hard to fix.
The precise best way to use the set command to set the arguments without disrupting the value(s) of shell options varies from one shell ver-
sion to another.
BSD November 28, 2009 BSD