04-12-2010
bash changing file name
I want to run some unix commands on one file..let say if i change the name and that name of file is present already. I dnt want to change that presnt file but instead of that make another one with different name
eg.. usa.txt if it is there make usa.txt.1 something like that
Also one more thing I was confuse with was is it possible when we append somehing in a file..is it possible that it will again change the persmissions of the files automatically without using chmod
Last edited by Learnerabc; 04-12-2010 at 08:19 PM..
Reason: spell mistake
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi guys,
I am converting a bash script to perl. I need lots of help and pointers on how to make the script work. Any help would be greatly appreciated. Here is what I have:
#!/usr/bin/perl
#Decrypt Files
$dir = "/usr/bin/gpg;
opendir(PGP_DIR, $dir) || die "can't opendir $dir: $!";... (3 Replies)
Discussion started by: freak
3 Replies
2. Shell Programming and Scripting
I am doing a basic script to check if services are disabled, and I was wondering how to change to colours for PASS and FAIL to green & red respectively.
#!/usr/bin/bash
clear
TELNET=`svcs -a | grep telnet | awk '{print $1}'`
if
then
RESULT=PASS
else
RESULT=FAIL
fi... (3 Replies)
Discussion started by: detatchedd
3 Replies
3. Shell Programming and Scripting
I need some help recovering from a "slight" screwup. We just moved 3 TB of data from one RAID Array to another. Low lever archive files. This was done with a regular cp (for some reason) and now we have lost all the timestamps on the files, and we urgently need to get the timestamps back on these... (7 Replies)
Discussion started by: chj
7 Replies
4. Shell Programming and Scripting
How can I change the cron entries only for ABC and XYZ from dosomething_1.0.sh to nowchanged_2.0 using a bash script ?
Any help will be appreciated.
#
# ABC
00,05,10,15,20,25,30,35,40,45,50,55 * * * * /mydir/dosomething_1.0.sh 1>/dev/null 2>&1
#
#
##
# DEF... (4 Replies)
Discussion started by: jville
4 Replies
5. Shell Programming and Scripting
Hello!
I need to write a bash script for my university classes, and I came up with an idea of a program that would test the speed of typing - there is some random text that you have to rewrite, and the script measures time, number of mistakes etc. The text would be visible on the screen all... (3 Replies)
Discussion started by: xqwzts
3 Replies
6. HP-UX
According to multiple sources you should not change the default shell to bash for the root user because it will make the system unbootable.
Is there a safe way to launch bash for root when logging in? Perhaps I can edit /etc/profile or add it to a startup script somewhere? (2 Replies)
Discussion started by: bstring
2 Replies
7. Shell Programming and Scripting
Hello Guys
I have a script working fine on csh, but I would like to change it to bash, how I should change this command to be able to work as bash script. :wall:
if ( $fsw > "0" ) then
foreach swath ( `awk 'BEGIN {for (i='$fsw';i<='$lsw';i++) printf ("%s\n", i) }'` )
## work to be done... (2 Replies)
Discussion started by: jiam912
2 Replies
8. Shell Programming and Scripting
I have a function in bash that takes arguments. does IFS work in a function or does it apply only to the main script? (1 Reply)
Discussion started by: kristinu
1 Replies
9. Shell Programming and Scripting
I am trying to change dates in a bash script.
I have a start time and an endtime and want to increment the times. Basically
the month and day have to be incremented in a loop to create two strings, stm and
etm defining the start and end times.
stm="2014-05-13T00:00:00"... (4 Replies)
Discussion started by: novilatte
4 Replies
10. Shell Programming and Scripting
Hello,
I want to run a script written in ksh but my default shell is bash as root e.g in the script it has #!/bin/ksh
i have gone into /etc/passwd to change it from :/bin/bash to /bin/ksh
but still giving me an error when running scripts such as ./installer
-bash: ./installer: /bin/ksh:... (3 Replies)
Discussion started by: DOkuwa
3 Replies
LEARN ABOUT OPENDARWIN
chsh
CHSH(1) User Commands CHSH(1)
NAME
chsh - change login shell
SYNOPSIS
chsh [options] [LOGIN]
DESCRIPTION
The chsh command changes the user login shell. This determines the name of the user's initial login command. A normal user may only change
the login shell for her own account; the superuser may change the login shell for any account.
OPTIONS
The options which apply to the chsh command are:
-h, --help
Display help message and exit.
-R, --root CHROOT_DIR
Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.
-s, --shell SHELL
The name of the user's new login shell. Setting this field to blank causes the system to select the default login shell.
If the -s option is not selected, chsh operates in an interactive fashion, prompting the user with the current login shell. Enter the new
value to change the shell, or leave the line blank to use the current one. The current shell is displayed between a pair of [ ] marks.
NOTE
The only restriction placed on the login shell is that the command name must be listed in /etc/shells, unless the invoker is the superuser,
and then any value may be added. An account with a restricted login shell may not change her login shell. For this reason, placing /bin/rsh
in /etc/shells is discouraged since accidentally changing to a restricted shell would prevent the user from ever changing her login shell
back to its original value.
FILES
/etc/passwd
User account information.
/etc/shells
List of valid login shells.
/etc/login.defs
Shadow password suite configuration.
SEE ALSO
chfn(1), login.defs(5), passwd(5).
shadow-utils 4.5 01/25/2018 CHSH(1)