nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

save command and command output

This is a discussion on save command and command output within the CentOS / RHEL / Fedora forums, part of the Linux Distribution category; Dear forum friends, I have a shell script which contains 5 linux commands. I want to save both commands as ...


Go Back   nixCraft Linux Forum > Linux Distribution > CentOS / RHEL / Fedora

Linux answers from nixCraft.


CentOS / RHEL / Fedora Discussion about Redhat Enterprise Linux or CentOS or Fedora Linux related problems.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 22-04-2009, 07:02 PM
Junior Member
User
 
Join Date: Apr 2009
OS: RHEL
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
savook is on a distinguished road
Default save command and command output

Dear forum friends,

I have a shell script which contains 5 linux commands. I want to save both commands as well as each command output into separate log file. How can I do this.

Thanks & regards
Savook
Reply With Quote
  #2 (permalink)  
Old 08-05-2009, 05:33 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 246 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Yes, you can do it as follows:
Code:
#!/bin/bash
MEM=/tmp/memory.output
CPU=/tmp/cpuinfo.output

echo "Memory output: " >$MEM
free -m >> $MEM


echo "CPU output: " >$CPU
cat /proc/cpuinfo >> $CPU
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply

Tags
cat , command output , free , shell scripting , unix command output to a file


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
print a "FTP dir command" output into a .txt file ecompean Shell scripting 2 09-02-2009 11:34 PM
Automate command execution - reboot-command execution ganeshp@moris.org Shell scripting 2 03-12-2008 11:18 AM
How can I redirect the output of time command to file warren Linux software 13 25-08-2006 11:17 AM
How do I use the tar command? jerry All about FreeBSD/OpenBSD/NetBSD 1 22-06-2006 02:05 PM
How can I get some specific characters of dd command output warren Shell scripting 2 24-05-2006 03:59 PM


All times are GMT +5.5. The time now is 06:04 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38