Jump to content
  • Advertisement
Sign in to follow this  
Instigator

commands to variables UNIX

This topic is 4398 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there anyway to convert a command into a variable. This is what I figured would work. However, it doesn't
Quote:
let capital = 'cut -d: -f1 finalD.ca'
I'm trying to assign the output from 'cut' into a variable. this is how the file FinalD.ca looks (there's only one line in the file).
Quote:
something:29342:20329
That's all that's in the file. Why doesn't let capital = 'cut -d: -f1 finalD.ca' Work? Any help would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
at the top of my script I've got

#!/bin/sh

and when I try

capital = $(cut -d: -f1 finalD.ca)

I get an error: "command capital" not found.

Share this post


Link to post
Share on other sites

You can also do it like this:

MYVAR=`ls`
echo $MYVAR

Note that Im not using the single quotes ' but the other kind `
(dont know what it is called)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!