LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using command line expansions... (https://www.linuxquestions.org/questions/linux-newbie-8/using-command-line-expansions-875994/)

BMan8577 04-19-2011 06:32 PM

Using command line expansions...
 
I am to create a variable called LINUX_VERS that contains the first line of the file /var/log/dmesg. The file is to be regenerated each time machine boots (in which it is dynamically implemented). I know that the head-1 command lists files with first line. How do I input this into the .bashrc file? Also if you are being asked to create files in which the contents of the files are irrelevant, what does that mean? Thanks guys for helping me understand Linux.

Tinkster 04-19-2011 06:39 PM

The second part sounds very much like homework; what's the rationale
behind your requests?


Cheers,
Tink

BMan8577 04-19-2011 06:47 PM

Hey that's cool. Whatever works and yes all this is homework. The second part is creating the files: untitled file, **'s and ||'s, and >> README!! <<. The first part I need guidance too...lol. Thanks I appreciate your help.

---------- Post added 04-19-11 at 07:48 PM ----------

whatever you can provide me with to help me is cool, don't have to do my homework but some good examples or something would help.

chrism01 04-19-2011 07:00 PM

I'd definitely bookmark & read

http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

in that order.

As for the file qn; consider that creating a file does not require you to put any content into it.
There's a cmd for that if you look at those links and or google around.

Good luck :)

Telengard 04-19-2011 07:10 PM

Quote:

Originally Posted by Tinkster (Post 4329928)
sounds very much like homework

+1

@OP, I think you should look into command substitution. You can use it with the other commands mentioned to extract certain parts of a file.

BMan8577 04-19-2011 11:46 PM

Can this command for the first part be an alternative? I just want to make sure that this would work in the .bashrc file. What I did was join the two commands (the second command I know would only work if the first command is successful) like so: VAR="$VAR{LINUX_VERS}";head -1 /var/log/dmesg. Would this be a solution to regenerating the /var/log/dmesg so the variable LINUX_VERS is set dynamically when machine is booted? And if I do not get it right could someone let me know? I just do not want to clobber or screw up the ~/.bashrc file. Thanks guys and thanks for the links.


All times are GMT -5. The time now is 03:20 PM.