> How to save and execute terminal commands in shell? | Unix Linux Forums | Shell Programming and Scripting

  Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

How to save and execute terminal commands in shell?

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-25-2013
Akshay Hegde's Unix or Linux Image
Akshay Hegde Akshay Hegde is offline Forum Advisor  
Forum Advisor
 
Join Date: Nov 2012
Last Activity: 26 July 2016, 2:03 AM EDT
Location: Dona Paula, Panjim, Goa - 403004
Posts: 1,760
Thanks: 97
Thanked 608 Times in 543 Posts
How to save and execute terminal commands in shell?

I frequently use some commands, which I want to save in some file say
Code:
myregularshell.sh

these are the commands I use, I tried saving and executing, but couldn't get the preview of execution, and result is also not coming if I copy same commands and paste it on terminal result is coming



Code:
cd go somewhere

echo "I am here $PWD"

sudo su

source /etc/profile

sh operation.sh arguments

echo "Operation over"

find /mypath/path iname "*.abc" -delete

echo "old files deleted"

mv -i *.xyz /mypath/path 

echo "new files moved "


Is there any way to save as shell script and execute ?
Sponsored Links
    #2  
Old Unix and Linux 01-25-2013
posix's Unix or Linux Image
posix posix is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 30 March 2016, 3:58 AM EDT
Location: grep "Bhubaneswar" "india"
Posts: 192
Thanks: 8
Thanked 13 Times in 13 Posts
Preview of execution can be done using "set", Please add this line into you script

Code:
 
set -vx

Sponsored Links
    #3  
Old Unix and Linux 01-25-2013
Akshay Hegde's Unix or Linux Image
Akshay Hegde Akshay Hegde is offline Forum Advisor  
Forum Advisor
 
Join Date: Nov 2012
Last Activity: 26 July 2016, 2:03 AM EDT
Location: Dona Paula, Panjim, Goa - 403004
Posts: 1,760
Thanks: 97
Thanked 608 Times in 543 Posts
no, if I logout from root then I could see from
Code:
set -vx

, but if I logout from root I will get permission denied error
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell: How to execute commands from another file? Alkali Shell Programming and Scripting 3 03-03-2012 06:07 PM
Shell script to execute commands in individual users' home directories rupa_lahiri Shell Programming and Scripting 1 11-03-2009 07:48 AM
execute shell commands with in sftp tommy1 Shell Programming and Scripting 5 02-17-2009 07:13 PM
Can BASH execute commands on a remote server when the commands are embedded in shell bash_in_my_head Shell Programming and Scripting 1 12-04-2008 12:51 AM
how to execute shell commands in awk script? RishiPahuja Shell Programming and Scripting 1 09-02-2005 09:37 AM



All times are GMT -4. The time now is 11:42 PM.