LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-10-2007, 09:26 PM   #1
nadeemr
LQ Newbie
 
Registered: May 2007
Posts: 18

Rep: Reputation: 0
how to use temporary files?


my dilema is that:
i am trying to write a shell script 'shortcut' that does the following:

[nruhomutally@dblsys bin]$./shortcut -a myls ls -lart # Associates the tag 'myls' with the command 'ls -lart'
[nruhomutally@dblsys bin]$./shortcut myls # runs 'ls -lart'
[nruhomutally@dblsys bin]$./shortcut -d myls
OK, shortcut 'myls' deleted
[nruhomutally@dblsys bin]$
[nruhomutally@dblsys bin]$.shortcut -l myls
Shortcut 'myls' = ls -lart
[nruhomutally@dblsys bin]$
 
Old 06-11-2007, 12:02 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
So is your question about temporary files, or about how to write the script?

If your question is about temporary files, what is your question?

If your question is about how to write the script, and you don't know much about shell scripting, get cracking and learn it! (grins) Google for

Code:
bash tutorial
Otherwise, maybe you want to post the script you have written so far and ask a specific question about it.

Hope this helps you get started.
 
Old 06-11-2007, 12:14 AM   #3
St.Jimmy
Member
 
Registered: Jun 2006
Location: Boaz,Alabama
Distribution: Ubuntu 10.10 / Windows 7 Pro 64-Bit / Snow Leopard 10.6.4 64-Bit
Posts: 152

Rep: Reputation: 30
you should just be able to use alias.
 
Old 06-11-2007, 06:31 AM   #4
nadeemr
LQ Newbie
 
Registered: May 2007
Posts: 18

Original Poster
Rep: Reputation: 0
i would need to write a temporary file that outputs :

[nruhomutally@dblsys bin]$./shortcut -a myls ls -lart # Associates the tag 'myls' with the command 'ls -lart'
[nruhomutally@dblsys bin]$./shortcut myls # runs 'ls -lart'
[nruhomutally@dblsys bin]$./shortcut -d myls
OK, shortcut 'myls' deleted
[nruhomutally@dblsys bin]$
[nruhomutally@dblsys bin]$.shortcut -l myls
Shortcut 'myls' = ls -lart
[nruhomutally@dblsys bin]$

any help would be much appreciated!

Last edited by nadeemr; 06-11-2007 at 10:11 PM.
 
Old 06-11-2007, 01:39 PM   #5
St.Jimmy
Member
 
Registered: Jun 2006
Location: Boaz,Alabama
Distribution: Ubuntu 10.10 / Windows 7 Pro 64-Bit / Snow Leopard 10.6.4 64-Bit
Posts: 152

Rep: Reputation: 30
There is mo reason to write that script,, AFAIK, just use alias.
 
Old 06-11-2007, 10:10 PM   #6
nadeemr
LQ Newbie
 
Registered: May 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by St.Jimmy
There is mo reason to write that script,, AFAIK, just use alias.
Can u be more specific with the use of alias!?
 
Old 06-11-2007, 11:23 PM   #7
St.Jimmy
Member
 
Registered: Jun 2006
Location: Boaz,Alabama
Distribution: Ubuntu 10.10 / Windows 7 Pro 64-Bit / Snow Leopard 10.6.4 64-Bit
Posts: 152

Rep: Reputation: 30
alias rm="rm -rf" //changes every instance of rm to rm -rf
alias -a //removes all aliases
alias -t //lists all tracked aliases
alias -x //lists all exported aliases
unalias rm //removes the alias above
 
Old 06-12-2007, 07:29 AM   #8
nadeemr
LQ Newbie
 
Registered: May 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by St.Jimmy
alias rm="rm -rf" //changes every instance of rm to rm -rf
alias -a //removes all aliases
alias -t //lists all tracked aliases
alias -x //lists all exported aliases
unalias rm //removes the alias above
ok what is this code suppose to do...coz i tried it and its not working
 
Old 06-12-2007, 08:49 AM   #9
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
They don't work for me either. Some of them (not all) work better in ksh, but I'll bet you're using bash.

Try these:

Code:
alias rm="rm -rf" # changes every instance of rm to rm -rf
alias             # lists   all aliases
unalias -a        # removes all aliases
unalias rm        # removes the alias for rm
 
Old 06-12-2007, 12:02 PM   #10
nadeemr
LQ Newbie
 
Registered: May 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wjevans_7d1@yahoo.co
They don't work for me either. Some of them (not all) work better in ksh, but I'll bet you're using bash.

Try these:

Code:
alias rm="rm -rf" # changes every instance of rm to rm -rf
alias             # lists   all aliases
unalias -a        # removes all aliases
unalias rm        # removes the alias for rm

yes am using bash!
 
Old 06-12-2007, 12:18 PM   #11
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
edit your .bashrc file in your home directory and add an alias:

Code:
cd ~
vi .bashrc
Now you need to add this line under the other aliases:

Code:
alias myls='ls -lart'
Write and quit this file (:wq) and now you need to re read this file in order to use it:

Code:
source .bashrc
now you can just type: myls and it should work like a regular command.

Last edited by custangro; 06-12-2007 at 12:19 PM.
 
Old 06-14-2007, 03:52 PM   #12
nadeemr
LQ Newbie
 
Registered: May 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by custangro
edit your .bashrc file in your home directory and add an alias:

Code:
cd ~
vi .bashrc
Now you need to add this line under the other aliases:

Code:
alias myls='ls -lart'
Write and quit this file (:wq) and now you need to re read this file in order to use it:

Code:
source .bashrc
now you can just type: myls and it should work like a regular command.

it doesn't seems to work at all for me...please be more precise thank you
 
Old 06-15-2007, 11:45 AM   #13
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
After you've made custangro's recommended changes to the .bashrc file in your home directory and you've typed source .bashrc, when you type myls, what error message do you get?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing temporary files joe-uncle Linux - Newbie 3 10-29-2004 11:51 AM
Temporary Internet Files?????????? RobTek Linux - Newbie 12 10-25-2004 07:20 PM
crontab & quota files are temporary files? hamish Linux - Software 0 07-10-2004 02:09 PM
Temporary Files Full? Killer7 Linux - Software 8 02-07-2004 04:27 PM
Clearing Temporary Files jjorloff1 Red Hat 1 01-25-2004 07:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration