LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 04-19-2011, 07:32 PM   #1
BMan8577
Member
 
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
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


Cheers,
Tink

Last edited by Tinkster; 04-19-2011 at 07:46 PM.
 
Old 04-19-2011, 07:47 PM   #3
BMan8577
Member
 
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 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.
 
Old 04-19-2011, 08:00 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

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

Rep: Reputation: 147Reputation: 147
Quote:
Originally Posted by Tinkster View Post
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.
 
Old 04-20-2011, 12:46 AM   #6
BMan8577
Member
 
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.
 
  


Reply


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


All times are GMT -5. The time now is 06:13 AM.

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