Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-19-2011, 07:32 PM   #1
Registered: Apr 2011
Posts: 73

Rep: Reputation: 0
Question 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.
Old 04-19-2011, 07:39 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


Last edited by Tinkster; 04-19-2011 at 07:46 PM.
Old 04-19-2011, 07:47 PM   #3
Registered: Apr 2011
Posts: 73

Original Poster
Rep: Reputation: 0
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 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.
Old 04-19-2011, 08:00 PM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,569

Rep: Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427Reputation: 2427
I'd definitely bookmark & read

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
Old 04-19-2011, 08:10 PM   #5
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 148Reputation: 148
Originally Posted by Tinkster View Post
sounds very much like homework

@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.
Old 04-20-2011, 12:46 AM   #6
Registered: Apr 2011
Posts: 73

Original Poster
Rep: Reputation: 0
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.

Last edited by BMan8577; 04-20-2011 at 12:47 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Print all PID folders from /proc line-by-line with this format (( PID: command-line )) courteous Linux - Newbie 7 12-12-2010 05:47 PM
awk command line: blank line record sep, new line field sep robertmarkbram Programming 4 02-21-2010 06:25 AM
LXer: Some Linux Audio Updates And Expansions LXer Syndicated Linux News 0 11-21-2007 11:10 AM
xine command line? or some other command line only engine? lumix Linux - Software 2 08-10-2007 11:46 AM
BASH string expansions Barbarian Programming 2 11-21-2001 11:40 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration