I am attempting to make a recycling bin type application in shell script (tcsh). I have the whole part of the application done where someone can recycle files from one location to the recycling bin (the lower half of the program), this is not a problem. However I wanted to make another option if the user typed in something like recycle -cleanup as argument 1 it would go into a loop to check each file currently in the recycling bin and ask the user what to do. If the user chooses d, it deletes it. If they choose s it skips it, and lastly if they choose r I want to restore it. This is where the problem lies.
I am very inexperienced with shell programming in general so I am not even sure if the way I'm doing the -cleanup thing is right. But, is there a way to know the original file location so I can just put the file back? First check that there is not a file with a duplicate name in the old directory, then if not move it back. As of now I have no clue how to do this and any help would greatly be appreciated!
Thank you! This is what I have so far:
---------- Post updated at 04:16 PM ---------- Previous update was at 03:54 PM ----------
help please
i have "inherited" a Sco Server (the administrator departed in a hurry...yes we are chasing him..) and haven't used Unix for 8 years.
i have a file that i need to retrieve from a tape.
i have been able to find the file on tape using the cpio -ivt command.
however...
the problem I... (3 Replies)
Is it possible to restore a TAR'ed file off of a tape to a location other than the original location? If so, how?
(The MAN pages give examples of how to restore only to the originating location.)
Thanks!! (1 Reply)
I'm new to Unix and have just wrote a little program to move files to a recycle bin (a Directory i created) and restore them. The problem is that i need to keep track of all the full filenames so that i can restore them to the right place. I did this by creating a file called delreg and putting the... (4 Replies)
Hello everyone,
I am new to unix shell.
I have a file called Path.txt....and i have data in that as
1 abhi
2 avi
3 ash so on.....
1 ,2 ,3 is the... (2 Replies)
Hello,
Question is related to Perl:
I need to search few of the files from the array of file names.
And after grepping the file names from an array I need to link these files to original location. The original location in this case is ref_path as input from the user.
##$ref_path is... (3 Replies)
Hi,
I am logging to a linux server through a user "user1" in /home directory.
There is a script in a directory in 'root' for which all permissions are available including the directory. This script when executed creates a file in the directory.
When the script is added to crontab, on... (1 Reply)
I have file file1.txt in location 'loc1'. Now i want a copy of this file in location 'loc2' with a new file called test.txt.
Please help me how to do this in shell script. (1 Reply)
:EDIT:
I think my post name should have been labeled: how to copy files and record original file location. not "retain".
Hello, this is my first post! I searched the forums a lot before posting, but was unable to answer my question.
Here's my problem:
There are several hundred text files... (4 Replies)
Hi
This is my third past and very impressed with previous post replies
Hoping the same for below query
How to find a existing file location and directory location in solaris box (1 Reply)
Discussion started by: buzzme
1 Replies
LEARN ABOUT SUNOS
echo
echo(1) User Commands echo(1)NAME
echo - echo arguments
SYNOPSIS
/usr/bin/echo [string...]
DESCRIPTION
The echo utility writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. If there are no arguments,
only the NEWLINE character will be written.
echo is useful for producing diagnostics in command files, for sending known data into a pipe, and for displaying the contents of environ-
ment variables.
The C shell, the Korn shell, and the Bourne shell all have echo built-in commands, which, by default, will be invoked if the user calls
echo without a full pathname. See shell_builtins(1). sh's echo, ksh's echo, and /usr/bin/echo understand the back-slashed escape charac-
ters, except that sh's echo does not understand a as the alert character. In addition, ksh's echo, does not have an -n option. sh's echo
and /usr/bin/echo only have an -n option if the SYSV3 environment variable is set (see ENVIRONMENT VARIABLES below). If it is, none of the
backslashed characters mentioned above are available. csh's echo and /usr/ucb/echo, on the other hand, have an -n option, but do not under-
stand the back-slashed escape characters.
OPERANDS
The following operand is supported:
string A string to be written to standard output. If any operand is "-n", it will be treated as a string, not an option. The following
character sequences will be recognized within any of the arguments:
a Alert character.
Backspace.
c Print line without new-line. All characters following the c in the argument are ignored.
f Form-feed.
New-line.
Carriage return.
Tab.
v Vertical tab.
\ Backslash.
n Where n is the 8-bit character whose ASCII code is the 1-, 2- or 3-digit octal number representing that character.
USAGE
Portable applications should not use -n (as the first argument) or escape sequences.
The printf(1) utility can be used portably to emulate any of the traditional behaviors of the echo utility as follows:
o The Solaris 2.6 operating environment or compatible version's /usr/bin/echo is equivalent to:
printf "%b
" "$*"
o The /usr/ucb/echo is equivalent to:
if [ "X$1" = "X-n" ]
then
shift
printf "%s" "$*"
else
printf "%s
" "$*"
fi
New applications are encouraged to use printf instead of echo.
EXAMPLES
Example 1: Finding how far below root your current directory is located
You can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows:
o Echo your current-working-directory's full pathname.
o Pipe the output through tr to translate the path's embedded slash-characters into space-characters.
o Pipe that output through wc -w for a count of the names in your path.
example% /usr/bin/echo $PWD | tr '/' ' ' | wc -w
See tr(1) and wc(1) for their functionality.
Below are the different flavors for echoing a string without a NEWLINE:
Example 2: /usr/bin/echo
example% /usr/bin/echo "$USER's current directory is $PWDc"
Example 3: sh/ksh shells
example$ echo "$USER's current directory is $PWDc"
Example 4: csh shell
example% echo -n "$USER's current directory is $PWD"
Example 5: /usr/ucb/echo
example% /usr/ucb/echo -n "$USER's current directory is $PWD"
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of echo: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
SYSV3 This environment variable is used to provide compatibility with INTERACTIVE UNIX System and SCO UNIX installation scripts. It is
intended for compatibility only and should not be used in new scripts.
EXIT STATUS
The following error values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO echo(1B), printf(1), shell_builtins(1), tr(1), wc(1), ascii(5), attributes(5), environ(5), standards(5)NOTES
When representing an 8-bit character by using the escape convention n, the n must always be preceded by the digit zero(0).
For example, typing: echo 'WARNING: 7' will print the phrase WARNING: and sound the "bell" on your terminal. The use of single (or double)
quotes (or two backslashes) is required to protect the "" that precedes the "07".
Following the , up to three digits are used in constructing the octal output character. If, following the n, you want to echo addi-
tional digits that are not part of the octal representation, you must use the full 3-digit n. For example, if you want to echo "ESC 7" you
must use the three digits "033" rather than just the two digits "33" after the .
2 digits Incorrect: echo"0337 | od -xc
produces: df0a (hex)
337 (ascii)
3 digits Correct: echo "00337" | od -xc
produces: lb37 0a00 (hex)
033 7 (ascii)
For the octal equivalents of each character, see ascii(5).
SunOS 5.10 20 Jan 2000 echo(1)