LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 04-10-2013, 01:08 PM   #1
Bazzaah
Member
 
Registered: Mar 2007
Distribution: Slackware64-current, Slackware64 14
Posts: 323

Rep: Reputation: 49
bash scripting question


I realise that this might be in the wrong forum so please move mods if you feel the need, but it is a Slackware specific question.

I've been playing with a script to automate kernel compilation (to some extent).

The commands I use come from AlienBob's guide and I know they work.

My question is this - would the first three lines of code take the user input and insert that input into the variable $kernel in line 4? I think it does but would like to check.

Code:
#!/bin/bash
1. echo -n "Which kernel?"
2. read kernel
3. echo "kernel $KERNEL"
4. tar -C /usr/src -Jxf linux-$kernel.tar.xz
...rest of script...
Thanks in advance
 
Old 04-10-2013, 01:23 PM   #2
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 1,632

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
No because the variables have case sensitive naming, $KERNEL is not the same as $kernel.

What is with the line numbers?

P.S. Also you don't need the J switch for tar. It will detect that it is XZ compressed automatically. You could rewite that line as:
Code:
tar xf linux-$kernel.tar.xz -C /usr/src
EDIT: Also why not just trying running the script and you would have seen if it worked or not?

Last edited by ruario; 04-10-2013 at 01:28 PM.
 
1 members found this post helpful.
Old 04-10-2013, 01:50 PM   #3
Bazzaah
Member
 
Registered: Mar 2007
Distribution: Slackware64-current, Slackware64 14
Posts: 323

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by ruario View Post
No because the variables have case sensitive naming, $KERNEL is not the same as $kernel.

What is with the line numbers?

P.S. Also you don't need the J switch for tar. It will detect that it is XZ compressed automatically. You could rewite that line as:
Code:
tar xf linux-$kernel.tar.xz -C /usr/src
EDIT: Also why not just trying running the script and you would have seen if it worked or not?
Thanks ruario.

I just added the line numbers to make my question clear - they don't appear in the script.

re your question, fair comment. I know little about bash scripting and wanted to check.
 
Old 04-10-2013, 01:58 PM   #4
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware-14.0 on a Lenovo T61 6457-4XG
Posts: 3,642

Rep: Reputation: 827Reputation: 827Reputation: 827Reputation: 827Reputation: 827Reputation: 827Reputation: 827
Small tip: when you request the user to enter data, use "read -e" instead of "read". This allows some line editing.
 
2 members found this post helpful.
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash scripting question rmarkin Linux - General 3 11-13-2008 01:52 PM
bash scripting question Locura Linux - General 5 09-02-2006 09:13 AM
Bash Scripting: Question About tr tvynr Linux - Software 16 09-01-2006 07:25 AM
Bash Scripting Question fiod Linux - Newbie 4 11-19-2005 05:09 AM
Bash Scripting Question Rezon Programming 2 10-30-2003 10:16 AM


All times are GMT -5. The time now is 10:50 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration