nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Shell Creates a variable that stores the results of the command

This is a discussion on Shell Creates a variable that stores the results of the command within the Shell scripting forums, part of the Development/Scripting category; i am a new writing script for UNIX i was wondering if anyone can help me with writing this script ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-16-2009, 05:43 PM
Junior Member
User
 
Join Date: Mar 2009
OS: Debian
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
blingbling is on a distinguished road
Default Shell Creates a variable that stores the results of the command

i am a new writing script for UNIX i was wondering if anyone can help me with writing this script cheers


. Creates a variable that stores the results of the command "ls –l"
. Directly calls the command "ls –l" (ie not through the variable)
. Displays a separating line (eg a line of – characters)
. Displays the value of the variable.
Reply With Quote
  #2 (permalink)  
Old 03-16-2009, 07:41 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,697
Thanks: 11
Thanked 243 Times in 183 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

Try

Code:
VAR=$(command-name)
VAR=$(ls -l)
echo $VAR
To display result
Code:
O=$IFS
IFS="\n"
echo $V
IFS=$O
__________________
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
$ifs , bash , echo , shell , shell variable


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
Can't Open folder from Search Results nabilalk Ubuntu / Debian 0 03-04-2009 12:46 AM
Squid with squidGuard - Server Creates more processes for squidGuard & then hangs cjagdish69@gmail.com Proxy Servers 0 09-23-2008 04:04 PM
Run mv command from ftp shell script subin Shell scripting 6 05-02-2008 09:44 AM
running command a root in shell scripts chiku Shell scripting 1 07-17-2006 06:39 PM
How to pass shell variable to awk program Shell scripting 4 06-23-2006 05:11 AM


All times are GMT +5.5. The time now is 02:17 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 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