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

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

How to save and execute terminal commands in shell?

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-25-2013
Akshay Hegde's Avatar
Akshay Hegde Akshay Hegde is offline Forum Advisor  
Forum Advisor
 
Join Date: Nov 2012
Last Activity: 19 December 2014, 12:38 PM EST
Location: Goa / Bangalore, India
Posts: 1,652
Thanks: 82
Thanked 543 Times in 494 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 01-25-2013
posix's Avatar
posix posix is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 10 December 2014, 10:01 AM EST
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 01-25-2013
Akshay Hegde's Avatar
Akshay Hegde Akshay Hegde is offline Forum Advisor  
Forum Advisor
 
Join Date: Nov 2012
Last Activity: 19 December 2014, 12:38 PM EST
Location: Goa / Bangalore, India
Posts: 1,652
Thanks: 82
Thanked 543 Times in 494 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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:07 PM
Shell script to execute commands in individual users' home directories rupa_lahiri Shell Programming and Scripting 1 11-03-2009 08:48 AM
execute shell commands with in sftp tommy1 Shell Programming and Scripting 5 02-17-2009 08: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 01:51 AM
how to execute shell commands in awk script? RishiPahuja Shell Programming and Scripting 1 09-02-2005 10:37 AM



All times are GMT -4. The time now is 05:31 PM.