- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 04:56 PM
11-21-2005 04:56 PM
Script help
I want output of both like
testin='ls -a'
output with that command how do that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 05:03 PM
11-21-2005 05:03 PM
Re: Script help
alias testin='ls -a'
testin would now give what 'ls -a' would give.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 05:08 PM
11-21-2005 05:08 PM
Re: Script help
testin=`ls -a`
echo $testin >> out.txt
and also i want to include that ls -a command to that file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 05:42 PM
11-21-2005 05:42 PM
Re: Script help
Also, you do not need to do echo $testin >> some_file, you need to do as follows.
testin >> some_file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 05:51 PM
11-21-2005 05:51 PM
Re: Script help
its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 05:55 PM
11-21-2005 05:55 PM
Re: Script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 06:01 PM
11-21-2005 06:01 PM
Re: Script help
i want to output the 'ls -a' to some file and also will include what command i executed for this output eg:'la -a'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 06:06 PM
11-21-2005 06:06 PM
Re: Script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 11:20 PM
11-21-2005 11:20 PM
Re: Script help
Perhaps this is what you want (by example):
# CMD="ls -l /var/tmp";{ echo executing: $CMD;$CMD; } > file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 01:59 AM
11-22-2005 01:59 AM
Re: Script help
echo â output from ls â a commandâ > file.out
testin=$(ls â a)
echo $testin >> file.out
in this case $( ) works just like the back tick ` `
Howard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 03:31 AM
11-22-2005 03:31 AM
Re: Script help
echo "output from ls -a command" > file.out
testin=$(ls -a)
echo $testin >> file.out
see if that prints better
stupid Word
Howard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 03:57 AM
11-22-2005 03:57 AM
Re: Script help
If you want to capture the output of the command as well as the executed command then "script" might be what you're looking for...man script(1)
cheers!
- Tags:
- Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 06:00 AM
01-05-2006 06:00 AM
Re: Script help
export testit=`ls -a`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 06:20 AM
01-05-2006 06:20 AM
Re: Script help
CMD="ls -a"
echo "$CMD" > /tmp/file
$CMD >> /tmp/file
This answers your question but is not very elegant. Setting a variable to the output of a command as you posted originally is not a good idea. It would work provided you put double quotes aruond the grave accented command provided there are not too many files present.
Suggest you just do:
ls -a > /tmp/file
and be done with it.