Sponsored Content
Top Forums Shell Programming and Scripting Is it possible to change paths inside a bash script? Post 302978981 by tomislav91 on Sunday 7th of August 2016 01:46:43 PM
Old 08-07-2016
I did my bash like this
Code:
echo -n "give a name for script [ENTER]: " 
read var_name 
var_dir="/root/Documents/test"
 unzip -o $var_name -d  $var_dir 
mv $var_dir/$var_name.c $var_dir/$var_name.d 
sed 's/#SOMETHING="none"/SOMETHING="none"/' configfile.txt 
service something restart

I did in your way Don, but when type a name of script, I used .zip extension. Should I, or just give a name? Why am I asking. Because when I wrote like this

Code:
var_dir="/root/Documents/test"
unzip -o "$1" -d  $var_dir
mv $var_dir/"$1".c $var_dir/"$1".d

script don't work, cause he can't move file because there is no a file like example_of_file.ZIP.C . Can you get a point? If I mv a file and add just a argument, he took and extension, but i don't want to, just a name.

Last edited by tomislav91; 08-07-2016 at 03:00 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rewriting file paths in XML file within bash script

Hi guys, I'm working on a large set of scripts to move files around several servers and manipulate them for our staff. Basically we're shooting things, the videos hit a server and then need organised due to the language they've been shot in. Our XML (designed for Apple's Final Cut Pro) is right... (6 Replies)
Discussion started by: omfgbunnies
6 Replies

2. UNIX for Dummies Questions & Answers

using awk inside bash script?

Hello, I'm trying to write a bash script that will query the current system time (OS X 10.6.6) and then convert the output from HH:MM:SS into time in seconds. The output of the system time command (systemsetup -gettime) is returned as: Time: HH:MM:SS so I wanted to use awk -F: to grab... (5 Replies)
Discussion started by: xaiu
5 Replies

3. Shell Programming and Scripting

Tracking change inside the script

we have more then 10 jobs scheduled in cronjob.. but we can see some of the script has been changed without any notification.. can we write any script which captures any changes inside the scripts with time of change and user name like .. or any other option apart from this ?? Plz help .. (4 Replies)
Discussion started by: netdbaind
4 Replies

4. UNIX Desktop Questions & Answers

Change name of files to their paths -- find loop

Dear All, I have many sub-folders but each of them have a file with same name but different data. I want to either move or copy them into a new folder but they need to have the path of where they are coming as part of their name... I have managed to find the files but dont know how to change... (2 Replies)
Discussion started by: A-V
2 Replies

5. Shell Programming and Scripting

How to change the color inside email using shell script?

hi, i want to send an email from unix using mailx command. mailx -s "subject" "email@abc.com" < email.txt Email.txt contains some file names that are transferred successfully and some that failed. so the files that got failed to tranfer, should be displayed in red color in the mail. is it... (1 Reply)
Discussion started by: Little
1 Replies

6. Shell Programming and Scripting

Why commands inside bash script lost effectiveness?

Hi, I have a bash script to run many system commands on CentOS machine, but I am puzzled by some commands had no effect on parent environment. For example, I want to refresh the desktop xdg menu when some processes added or deleted items from desktop xdg menu. If I run "killall gnome-panel"... (4 Replies)
Discussion started by: hce
4 Replies

7. Shell Programming and Scripting

Expect not working inside my Bash script

I am trying to execute expect command inside by small bash script to login into servers using key authentication method. My script is as follows: #!/bin/bash HOST=$1 /usr/bin/expect -c " spawn ssh -i /root/.ssh/id_rsa root@$HOST expect -exact "Enter... (3 Replies)
Discussion started by: John Wilson
3 Replies

8. Shell Programming and Scripting

Run bash command inside zsh script

Hi, I would like to run following code in bash inside a zsh script. (In this case is output unfortunately very different if you run it in zsh). I tried to put "bash" in front of the code but I obtained following error message "bash: do: No such file or directory " eve though I merged the whole... (7 Replies)
Discussion started by: kamcamonty
7 Replies

9. Shell Programming and Scripting

Aliases NOT working inside bash shell script

i have defined a function ln_s() for customizing the ln command in script1.sh. more script1.sh echo "Starting Execution" ./script2.sh echo "End of Execution" ln_s(){ ] && return ln -s "$1" "$2" } My script1.sh executes another script2.sh which has the following entry more script2.sh... (12 Replies)
Discussion started by: mohtashims
12 Replies

10. Shell Programming and Scripting

Make change to variable value inside of awk script

Hello, I have text data that looks like this, Mrv16a3102061815532D 6 6 0 0 0 0 999 V2000 -0.4018 1.9634 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 1.5509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 0.7259 ... (9 Replies)
Discussion started by: LMHmedchem
9 Replies
PadWalker(3)						User Contributed Perl Documentation					      PadWalker(3)

NAME
PadWalker - play with other peoples' lexical variables SYNOPSIS
use PadWalker qw(peek_my peek_our peek_sub closed_over); ... DESCRIPTION
PadWalker is a module which allows you to inspect (and even change!) lexical variables in any subroutine which called you. It will only show those variables which are in scope at the point of the call. PadWalker is particularly useful for debugging. It's even used by Perl's built-in debugger. (It can also be used for evil, of course.) I wouldn't recommend using PadWalker directly in production code, but it's your call. Some of the modules that use PadWalker internally are certainly safe for and useful in production. peek_my LEVEL peek_our LEVEL The LEVEL argument is interpreted just like the argument to "caller". So peek_my(0) returns a reference to a hash of all the "my" variables that are currently in scope; peek_my(1) returns a reference to a hash of all the "my" variables that are in scope at the point where the current sub was called, and so on. "peek_our" works in the same way, except that it lists the "our" variables rather than the "my" variables. The hash associates each variable name with a reference to its value. The variable names include the sigil, so the variable $x is represented by the string '$x'. For example: my $x = 12; my $h = peek_my (0); ${$h->{'$x'}}++; print $x; # prints 13 Or a more complex example: sub increment_my_x { my $h = peek_my (1); ${$h->{'$x'}}++; } my $x=5; increment_my_x; print $x; # prints 6 peek_sub SUB The "peek_sub" routine takes a coderef as its argument, and returns a hash of the "my" variables used in that sub. The values will usually be undefined unless the sub is in use (i.e. in the call-chain) at the time. On the other hand: my $x = "Hello!"; my $r = peek_sub(sub {$x})->{'$x'}; print "$$r "; # prints 'Hello!' If the sub defines several "my" variables with the same name, you'll get the last one. I don't know of any use for "peek_sub" that isn't broken as a result of this, and it will probably be deprecated in a future version in favour of some alternative interface. closed_over SUB "closed_over" is similar to "peek_sub", except that it only lists the "my" variables which are used in the subroutine but defined outside: in other words, the variables which it closes over. This does have reasonable uses: see Data::Dump::Streamer, for example (a future version of which may in fact use "closed_over"). set_closed_over SUB, HASH_REF "set_closed_over" reassigns the pad variables that are closed over by the subroutine. The second argument is a hash of references, much like the one returned from "closed_over". var_name LEVEL, VAR_REF var_name SUB, VAR_REF "var_name(sub, var_ref)" returns the name of the variable referred to by "var_ref", provided it is a "my" variable used in the sub. The "sub" parameter can be either a CODE reference or a number. If it's a number, it's treated the same way as the argument to "peek_my". For example, my $foo; print var_name(0, $foo); # prints '$foo' sub my_name { return var_name(1, shift); } print my_name($foo); # ditto AUTHOR
Robin Houston <robin@cpan.org> With contributions from Richard Soberberg, Jesse Luehrs and Yuval Kogman, bug-spotting from Peter Scott, Dave Mitchell and Goro Fuji, and suggestions from demerphq. SEE ALSO
Devel::LexAlias, Devel::Caller, Sub::Parameters COPYRIGHT
Copyright (c) 2000-2009, Robin Houston. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.16.3 2012-08-24 PadWalker(3)
All times are GMT -4. The time now is 01:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy