Jump to content
  • Advertisement
Sign in to follow this  
Instigator

commands to variables UNIX

This topic is 4319 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!