quick bash question

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-3
down vote

favorite












first I would like to say that I'm not a programmer or scripter. Below is a script I have if/when I wipe my PC and start from scratch. It's a basic script (more like just a collection of commands) to set up my user profile. In the section commented as "Installs needed software" I was wondering if there was a way to create a list of the software names (in the script) and then somehow have that list called and the dropped in for the apt-get install command. I know it's not needed but it is the way I would like to do things if possible. I don't know if this can be done with an array or something like that but I was wanting to install everything from just one line. Thank you in advanced for the help.



Justin



#/bin/bash

###################################

# Script Name: deploy.sh
# Creation Date: 28OCT15
# Completion Date: 17FEB18

###################################

# Modify /etc/fstab to include user defined devices

sudo echo >> /etc/fstab
sudo echo >> /etc/fstab
sudo echo "# User defined Devices" >> /etc/fstab
sudo echo >> /etc/fstab
sudo echo "#250G for Downloads/etc" >> /etc/fstab
sudo echo "UUID=9ba4afc0-f565-4bf4-b935-102352dccd2c /mnt/250G ext4 errors=remount-ro 0 2" >> /etc/fstab

# Installs needed software

sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo apt-get install autofs nfs-common handbrake-cli handbrake lame vim chromium-browser screen ffmpeg htop cdparanoia eyed3 vorbis-tools clementine

# Configures autofs

sudo echo >> /etc/auto.master
sudo echo "/- /etc/auto.direct" >> /etc/auto.master

sudo touch /etc/auto.direct

sudo echo "# /mnt/music -rw 192.168.0.20:/export/music" >> /etc/auto.direct
sudo echo "# /mnt/storage -rw 192.168.0.20:/export/storage" >> /etc/auto.direct
sudo echo "# /mnt/movies -rw 192.168.0.20:/export/movies" >> /etc/auto.direct
sudo echo "# /mnt/shows -rw 192.168.0.20:/export/shows" >> /etc/auto.direct
sudo echo "# /mnt/pictures -rw 192.168.0.20:/export/pictures" >> /etc/auto.direct
sudo echo >> /etc/auto.direct
sudo echo "/mnt/music -rw,hard,intr,nfsvers=3 192.168.0.20:/export/music" >> /etc/auto.direct
sudo echo "/mnt/storage -rw,hard,intr,nfsvers=3 192.168.0.20:/export/storage" >> /etc/auto.direct
sudo echo "/mnt/movies -rw,hard,intr,nfsvers=3 192.168.0.20:/export/movies" >> /etc/auto.direct
sudo echo "/mnt/shows -rw,hard,intr,nfsvers=3 192.168.0.20:/export/shows" >> /etc/auto.direct
sudo echo "/mnt/pictures -rw,hard,intr,nfsvers=3 192.168.0.20:/export/pictures" >> /etc/auto.direct

# Remove existing directories

rm -Rf $HOME/Music
rm -Rf $HOME/Pictures

# Create mount points for NFS shares

sudo mkdir /mnt/music
sudo mkdir /mnt/pictures
sudo mkdir /mnt/storage
sudo mkdir /mnt/movies
sudo mkdir /mnt/shows

#Create symbolic links in home folder

sudo ln -s /mnt/music $HOME/music
sudo ln -s /mnt/pictures $HOME/pictures
sudo ln -s /mnt/storage $HOME/storage
sudo ln -s /mnt/movies $HOME/Videos/movies
sudo ln -s /mnt/shows $HOME/Videos/shows
sudo ln -s /mnt/storage/Scripts/linux $HOME/scripts
sudo ln -s /mnt/250G/ $HOME/Downloads

# Restart needed services

sudo service autofs restart

# Generates .bash_aliases file with useful aliases

sudo echo >> $HOME/.bash_aliases
sudo echo "alias ls='ls --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias vi='vim'" >> $HOME/.bash_aliases
sudo echo "alias grep='egrep --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias fgrep='fgrep --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias egrep='egrep --color=auto'" >> $HOME/.bash_aliases

# Create $HOME/bin directory for personal bin location

mkdir $HOME/.bin

# Add scripts to above directory

sudo cp $HOME/scripts/bash/audio/extract.sh $HOME/.bin/
sudo cp $HOME/scripts/bash/audio/m4a2mp3.sh $HOME/.bin/
sudo cp $HOME/scripts/bash/video/mkv2mp4.sh $HOME/.bin/

# Not yet up to par for video quality
# sudo cp $HOME/scripts/bash/video/avi2mp4.sh $HOME/bin/






share|improve this question






















  • Yeah, you're right. Its really not needed. As you can see from @steeldriver's solution, the solution doesn't make your code any prettier or shorter. Passing already-installed-programs to apt isn't a problem either because it will simply skip them.
    – BoomShadow
    Feb 18 at 16:11






  • 1




    If you're wiping your PC often enough that you need a script to set up your environment again, then IMO it would be more useful to stop doing whatever it is that is breaking your system to the point that it needs re-installation. Re-install from scratch is not a common or recommended way of solving problems on Linux (i.e. Linux is not Windows). One reason this is important is that if you don't understand what the cause of the problem was, you'll probably just do it again in the future. It's better to find and fix the problem.
    – cas
    Feb 19 at 3:12






  • 1




    Could I trouble you for a more descriptive title for this post? It’s not quick and it’s not specific to bash. Perhaps something about installing software from a list?
    – Jeff Schaller
    Feb 20 at 3:24










  • I second Jeff's comment and I'd also suggest reading How to Ask.
    – Anthony Geoghegan
    Feb 20 at 10:21














up vote
-3
down vote

favorite












first I would like to say that I'm not a programmer or scripter. Below is a script I have if/when I wipe my PC and start from scratch. It's a basic script (more like just a collection of commands) to set up my user profile. In the section commented as "Installs needed software" I was wondering if there was a way to create a list of the software names (in the script) and then somehow have that list called and the dropped in for the apt-get install command. I know it's not needed but it is the way I would like to do things if possible. I don't know if this can be done with an array or something like that but I was wanting to install everything from just one line. Thank you in advanced for the help.



Justin



#/bin/bash

###################################

# Script Name: deploy.sh
# Creation Date: 28OCT15
# Completion Date: 17FEB18

###################################

# Modify /etc/fstab to include user defined devices

sudo echo >> /etc/fstab
sudo echo >> /etc/fstab
sudo echo "# User defined Devices" >> /etc/fstab
sudo echo >> /etc/fstab
sudo echo "#250G for Downloads/etc" >> /etc/fstab
sudo echo "UUID=9ba4afc0-f565-4bf4-b935-102352dccd2c /mnt/250G ext4 errors=remount-ro 0 2" >> /etc/fstab

# Installs needed software

sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo apt-get install autofs nfs-common handbrake-cli handbrake lame vim chromium-browser screen ffmpeg htop cdparanoia eyed3 vorbis-tools clementine

# Configures autofs

sudo echo >> /etc/auto.master
sudo echo "/- /etc/auto.direct" >> /etc/auto.master

sudo touch /etc/auto.direct

sudo echo "# /mnt/music -rw 192.168.0.20:/export/music" >> /etc/auto.direct
sudo echo "# /mnt/storage -rw 192.168.0.20:/export/storage" >> /etc/auto.direct
sudo echo "# /mnt/movies -rw 192.168.0.20:/export/movies" >> /etc/auto.direct
sudo echo "# /mnt/shows -rw 192.168.0.20:/export/shows" >> /etc/auto.direct
sudo echo "# /mnt/pictures -rw 192.168.0.20:/export/pictures" >> /etc/auto.direct
sudo echo >> /etc/auto.direct
sudo echo "/mnt/music -rw,hard,intr,nfsvers=3 192.168.0.20:/export/music" >> /etc/auto.direct
sudo echo "/mnt/storage -rw,hard,intr,nfsvers=3 192.168.0.20:/export/storage" >> /etc/auto.direct
sudo echo "/mnt/movies -rw,hard,intr,nfsvers=3 192.168.0.20:/export/movies" >> /etc/auto.direct
sudo echo "/mnt/shows -rw,hard,intr,nfsvers=3 192.168.0.20:/export/shows" >> /etc/auto.direct
sudo echo "/mnt/pictures -rw,hard,intr,nfsvers=3 192.168.0.20:/export/pictures" >> /etc/auto.direct

# Remove existing directories

rm -Rf $HOME/Music
rm -Rf $HOME/Pictures

# Create mount points for NFS shares

sudo mkdir /mnt/music
sudo mkdir /mnt/pictures
sudo mkdir /mnt/storage
sudo mkdir /mnt/movies
sudo mkdir /mnt/shows

#Create symbolic links in home folder

sudo ln -s /mnt/music $HOME/music
sudo ln -s /mnt/pictures $HOME/pictures
sudo ln -s /mnt/storage $HOME/storage
sudo ln -s /mnt/movies $HOME/Videos/movies
sudo ln -s /mnt/shows $HOME/Videos/shows
sudo ln -s /mnt/storage/Scripts/linux $HOME/scripts
sudo ln -s /mnt/250G/ $HOME/Downloads

# Restart needed services

sudo service autofs restart

# Generates .bash_aliases file with useful aliases

sudo echo >> $HOME/.bash_aliases
sudo echo "alias ls='ls --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias vi='vim'" >> $HOME/.bash_aliases
sudo echo "alias grep='egrep --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias fgrep='fgrep --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias egrep='egrep --color=auto'" >> $HOME/.bash_aliases

# Create $HOME/bin directory for personal bin location

mkdir $HOME/.bin

# Add scripts to above directory

sudo cp $HOME/scripts/bash/audio/extract.sh $HOME/.bin/
sudo cp $HOME/scripts/bash/audio/m4a2mp3.sh $HOME/.bin/
sudo cp $HOME/scripts/bash/video/mkv2mp4.sh $HOME/.bin/

# Not yet up to par for video quality
# sudo cp $HOME/scripts/bash/video/avi2mp4.sh $HOME/bin/






share|improve this question






















  • Yeah, you're right. Its really not needed. As you can see from @steeldriver's solution, the solution doesn't make your code any prettier or shorter. Passing already-installed-programs to apt isn't a problem either because it will simply skip them.
    – BoomShadow
    Feb 18 at 16:11






  • 1




    If you're wiping your PC often enough that you need a script to set up your environment again, then IMO it would be more useful to stop doing whatever it is that is breaking your system to the point that it needs re-installation. Re-install from scratch is not a common or recommended way of solving problems on Linux (i.e. Linux is not Windows). One reason this is important is that if you don't understand what the cause of the problem was, you'll probably just do it again in the future. It's better to find and fix the problem.
    – cas
    Feb 19 at 3:12






  • 1




    Could I trouble you for a more descriptive title for this post? It’s not quick and it’s not specific to bash. Perhaps something about installing software from a list?
    – Jeff Schaller
    Feb 20 at 3:24










  • I second Jeff's comment and I'd also suggest reading How to Ask.
    – Anthony Geoghegan
    Feb 20 at 10:21












up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











first I would like to say that I'm not a programmer or scripter. Below is a script I have if/when I wipe my PC and start from scratch. It's a basic script (more like just a collection of commands) to set up my user profile. In the section commented as "Installs needed software" I was wondering if there was a way to create a list of the software names (in the script) and then somehow have that list called and the dropped in for the apt-get install command. I know it's not needed but it is the way I would like to do things if possible. I don't know if this can be done with an array or something like that but I was wanting to install everything from just one line. Thank you in advanced for the help.



Justin



#/bin/bash

###################################

# Script Name: deploy.sh
# Creation Date: 28OCT15
# Completion Date: 17FEB18

###################################

# Modify /etc/fstab to include user defined devices

sudo echo >> /etc/fstab
sudo echo >> /etc/fstab
sudo echo "# User defined Devices" >> /etc/fstab
sudo echo >> /etc/fstab
sudo echo "#250G for Downloads/etc" >> /etc/fstab
sudo echo "UUID=9ba4afc0-f565-4bf4-b935-102352dccd2c /mnt/250G ext4 errors=remount-ro 0 2" >> /etc/fstab

# Installs needed software

sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo apt-get install autofs nfs-common handbrake-cli handbrake lame vim chromium-browser screen ffmpeg htop cdparanoia eyed3 vorbis-tools clementine

# Configures autofs

sudo echo >> /etc/auto.master
sudo echo "/- /etc/auto.direct" >> /etc/auto.master

sudo touch /etc/auto.direct

sudo echo "# /mnt/music -rw 192.168.0.20:/export/music" >> /etc/auto.direct
sudo echo "# /mnt/storage -rw 192.168.0.20:/export/storage" >> /etc/auto.direct
sudo echo "# /mnt/movies -rw 192.168.0.20:/export/movies" >> /etc/auto.direct
sudo echo "# /mnt/shows -rw 192.168.0.20:/export/shows" >> /etc/auto.direct
sudo echo "# /mnt/pictures -rw 192.168.0.20:/export/pictures" >> /etc/auto.direct
sudo echo >> /etc/auto.direct
sudo echo "/mnt/music -rw,hard,intr,nfsvers=3 192.168.0.20:/export/music" >> /etc/auto.direct
sudo echo "/mnt/storage -rw,hard,intr,nfsvers=3 192.168.0.20:/export/storage" >> /etc/auto.direct
sudo echo "/mnt/movies -rw,hard,intr,nfsvers=3 192.168.0.20:/export/movies" >> /etc/auto.direct
sudo echo "/mnt/shows -rw,hard,intr,nfsvers=3 192.168.0.20:/export/shows" >> /etc/auto.direct
sudo echo "/mnt/pictures -rw,hard,intr,nfsvers=3 192.168.0.20:/export/pictures" >> /etc/auto.direct

# Remove existing directories

rm -Rf $HOME/Music
rm -Rf $HOME/Pictures

# Create mount points for NFS shares

sudo mkdir /mnt/music
sudo mkdir /mnt/pictures
sudo mkdir /mnt/storage
sudo mkdir /mnt/movies
sudo mkdir /mnt/shows

#Create symbolic links in home folder

sudo ln -s /mnt/music $HOME/music
sudo ln -s /mnt/pictures $HOME/pictures
sudo ln -s /mnt/storage $HOME/storage
sudo ln -s /mnt/movies $HOME/Videos/movies
sudo ln -s /mnt/shows $HOME/Videos/shows
sudo ln -s /mnt/storage/Scripts/linux $HOME/scripts
sudo ln -s /mnt/250G/ $HOME/Downloads

# Restart needed services

sudo service autofs restart

# Generates .bash_aliases file with useful aliases

sudo echo >> $HOME/.bash_aliases
sudo echo "alias ls='ls --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias vi='vim'" >> $HOME/.bash_aliases
sudo echo "alias grep='egrep --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias fgrep='fgrep --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias egrep='egrep --color=auto'" >> $HOME/.bash_aliases

# Create $HOME/bin directory for personal bin location

mkdir $HOME/.bin

# Add scripts to above directory

sudo cp $HOME/scripts/bash/audio/extract.sh $HOME/.bin/
sudo cp $HOME/scripts/bash/audio/m4a2mp3.sh $HOME/.bin/
sudo cp $HOME/scripts/bash/video/mkv2mp4.sh $HOME/.bin/

# Not yet up to par for video quality
# sudo cp $HOME/scripts/bash/video/avi2mp4.sh $HOME/bin/






share|improve this question














first I would like to say that I'm not a programmer or scripter. Below is a script I have if/when I wipe my PC and start from scratch. It's a basic script (more like just a collection of commands) to set up my user profile. In the section commented as "Installs needed software" I was wondering if there was a way to create a list of the software names (in the script) and then somehow have that list called and the dropped in for the apt-get install command. I know it's not needed but it is the way I would like to do things if possible. I don't know if this can be done with an array or something like that but I was wanting to install everything from just one line. Thank you in advanced for the help.



Justin



#/bin/bash

###################################

# Script Name: deploy.sh
# Creation Date: 28OCT15
# Completion Date: 17FEB18

###################################

# Modify /etc/fstab to include user defined devices

sudo echo >> /etc/fstab
sudo echo >> /etc/fstab
sudo echo "# User defined Devices" >> /etc/fstab
sudo echo >> /etc/fstab
sudo echo "#250G for Downloads/etc" >> /etc/fstab
sudo echo "UUID=9ba4afc0-f565-4bf4-b935-102352dccd2c /mnt/250G ext4 errors=remount-ro 0 2" >> /etc/fstab

# Installs needed software

sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo apt-get install autofs nfs-common handbrake-cli handbrake lame vim chromium-browser screen ffmpeg htop cdparanoia eyed3 vorbis-tools clementine

# Configures autofs

sudo echo >> /etc/auto.master
sudo echo "/- /etc/auto.direct" >> /etc/auto.master

sudo touch /etc/auto.direct

sudo echo "# /mnt/music -rw 192.168.0.20:/export/music" >> /etc/auto.direct
sudo echo "# /mnt/storage -rw 192.168.0.20:/export/storage" >> /etc/auto.direct
sudo echo "# /mnt/movies -rw 192.168.0.20:/export/movies" >> /etc/auto.direct
sudo echo "# /mnt/shows -rw 192.168.0.20:/export/shows" >> /etc/auto.direct
sudo echo "# /mnt/pictures -rw 192.168.0.20:/export/pictures" >> /etc/auto.direct
sudo echo >> /etc/auto.direct
sudo echo "/mnt/music -rw,hard,intr,nfsvers=3 192.168.0.20:/export/music" >> /etc/auto.direct
sudo echo "/mnt/storage -rw,hard,intr,nfsvers=3 192.168.0.20:/export/storage" >> /etc/auto.direct
sudo echo "/mnt/movies -rw,hard,intr,nfsvers=3 192.168.0.20:/export/movies" >> /etc/auto.direct
sudo echo "/mnt/shows -rw,hard,intr,nfsvers=3 192.168.0.20:/export/shows" >> /etc/auto.direct
sudo echo "/mnt/pictures -rw,hard,intr,nfsvers=3 192.168.0.20:/export/pictures" >> /etc/auto.direct

# Remove existing directories

rm -Rf $HOME/Music
rm -Rf $HOME/Pictures

# Create mount points for NFS shares

sudo mkdir /mnt/music
sudo mkdir /mnt/pictures
sudo mkdir /mnt/storage
sudo mkdir /mnt/movies
sudo mkdir /mnt/shows

#Create symbolic links in home folder

sudo ln -s /mnt/music $HOME/music
sudo ln -s /mnt/pictures $HOME/pictures
sudo ln -s /mnt/storage $HOME/storage
sudo ln -s /mnt/movies $HOME/Videos/movies
sudo ln -s /mnt/shows $HOME/Videos/shows
sudo ln -s /mnt/storage/Scripts/linux $HOME/scripts
sudo ln -s /mnt/250G/ $HOME/Downloads

# Restart needed services

sudo service autofs restart

# Generates .bash_aliases file with useful aliases

sudo echo >> $HOME/.bash_aliases
sudo echo "alias ls='ls --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias vi='vim'" >> $HOME/.bash_aliases
sudo echo "alias grep='egrep --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias fgrep='fgrep --color=auto'" >> $HOME/.bash_aliases
sudo echo "alias egrep='egrep --color=auto'" >> $HOME/.bash_aliases

# Create $HOME/bin directory for personal bin location

mkdir $HOME/.bin

# Add scripts to above directory

sudo cp $HOME/scripts/bash/audio/extract.sh $HOME/.bin/
sudo cp $HOME/scripts/bash/audio/m4a2mp3.sh $HOME/.bin/
sudo cp $HOME/scripts/bash/video/mkv2mp4.sh $HOME/.bin/

# Not yet up to par for video quality
# sudo cp $HOME/scripts/bash/video/avi2mp4.sh $HOME/bin/








share|improve this question













share|improve this question




share|improve this question








edited Feb 18 at 15:31









Tomasz

8,04052560




8,04052560










asked Feb 18 at 15:28









Justin Keith

11




11











  • Yeah, you're right. Its really not needed. As you can see from @steeldriver's solution, the solution doesn't make your code any prettier or shorter. Passing already-installed-programs to apt isn't a problem either because it will simply skip them.
    – BoomShadow
    Feb 18 at 16:11






  • 1




    If you're wiping your PC often enough that you need a script to set up your environment again, then IMO it would be more useful to stop doing whatever it is that is breaking your system to the point that it needs re-installation. Re-install from scratch is not a common or recommended way of solving problems on Linux (i.e. Linux is not Windows). One reason this is important is that if you don't understand what the cause of the problem was, you'll probably just do it again in the future. It's better to find and fix the problem.
    – cas
    Feb 19 at 3:12






  • 1




    Could I trouble you for a more descriptive title for this post? It’s not quick and it’s not specific to bash. Perhaps something about installing software from a list?
    – Jeff Schaller
    Feb 20 at 3:24










  • I second Jeff's comment and I'd also suggest reading How to Ask.
    – Anthony Geoghegan
    Feb 20 at 10:21
















  • Yeah, you're right. Its really not needed. As you can see from @steeldriver's solution, the solution doesn't make your code any prettier or shorter. Passing already-installed-programs to apt isn't a problem either because it will simply skip them.
    – BoomShadow
    Feb 18 at 16:11






  • 1




    If you're wiping your PC often enough that you need a script to set up your environment again, then IMO it would be more useful to stop doing whatever it is that is breaking your system to the point that it needs re-installation. Re-install from scratch is not a common or recommended way of solving problems on Linux (i.e. Linux is not Windows). One reason this is important is that if you don't understand what the cause of the problem was, you'll probably just do it again in the future. It's better to find and fix the problem.
    – cas
    Feb 19 at 3:12






  • 1




    Could I trouble you for a more descriptive title for this post? It’s not quick and it’s not specific to bash. Perhaps something about installing software from a list?
    – Jeff Schaller
    Feb 20 at 3:24










  • I second Jeff's comment and I'd also suggest reading How to Ask.
    – Anthony Geoghegan
    Feb 20 at 10:21















Yeah, you're right. Its really not needed. As you can see from @steeldriver's solution, the solution doesn't make your code any prettier or shorter. Passing already-installed-programs to apt isn't a problem either because it will simply skip them.
– BoomShadow
Feb 18 at 16:11




Yeah, you're right. Its really not needed. As you can see from @steeldriver's solution, the solution doesn't make your code any prettier or shorter. Passing already-installed-programs to apt isn't a problem either because it will simply skip them.
– BoomShadow
Feb 18 at 16:11




1




1




If you're wiping your PC often enough that you need a script to set up your environment again, then IMO it would be more useful to stop doing whatever it is that is breaking your system to the point that it needs re-installation. Re-install from scratch is not a common or recommended way of solving problems on Linux (i.e. Linux is not Windows). One reason this is important is that if you don't understand what the cause of the problem was, you'll probably just do it again in the future. It's better to find and fix the problem.
– cas
Feb 19 at 3:12




If you're wiping your PC often enough that you need a script to set up your environment again, then IMO it would be more useful to stop doing whatever it is that is breaking your system to the point that it needs re-installation. Re-install from scratch is not a common or recommended way of solving problems on Linux (i.e. Linux is not Windows). One reason this is important is that if you don't understand what the cause of the problem was, you'll probably just do it again in the future. It's better to find and fix the problem.
– cas
Feb 19 at 3:12




1




1




Could I trouble you for a more descriptive title for this post? It’s not quick and it’s not specific to bash. Perhaps something about installing software from a list?
– Jeff Schaller
Feb 20 at 3:24




Could I trouble you for a more descriptive title for this post? It’s not quick and it’s not specific to bash. Perhaps something about installing software from a list?
– Jeff Schaller
Feb 20 at 3:24












I second Jeff's comment and I'd also suggest reading How to Ask.
– Anthony Geoghegan
Feb 20 at 10:21




I second Jeff's comment and I'd also suggest reading How to Ask.
– Anthony Geoghegan
Feb 20 at 10:21










2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










One way to simplify the script is to take out all the sudo calls and call the entire script with sudo



#!/bin/bash
if [[ $(id -un) != root ]]; then
echo "invoke me with sudo: sudo $0"
exit
fi

echo >> /etc/fstab
# etc


Also note that you can put newlines inside an array definition to make it more readable:



pkgs=(
autofs lame vim nfs-common handbrake-cli handbrake chromium-browser
screen eyed3 htop clementine vorbis-tools cdparanoia ffmpeg
)





share|improve this answer






















  • Thank you, this wasn't what I was looking for in my question but it is helpful and I will be using this.
    – Justin Keith
    Feb 18 at 17:56

















up vote
2
down vote













You may use an array



pkgs=(autofs nfs-common handbrake-cli handbrake lame vim chromium-browser screen ffmpeg htop cdparanoia eyed3 vorbis-tools clementine)

sudo apt-get install "$pkgs[@]"





share|improve this answer




















  • Thank you, this answers my question. I will be updating my script to reflect this.
    – Justin Keith
    Feb 18 at 17:55










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f424978%2fquick-bash-question%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










One way to simplify the script is to take out all the sudo calls and call the entire script with sudo



#!/bin/bash
if [[ $(id -un) != root ]]; then
echo "invoke me with sudo: sudo $0"
exit
fi

echo >> /etc/fstab
# etc


Also note that you can put newlines inside an array definition to make it more readable:



pkgs=(
autofs lame vim nfs-common handbrake-cli handbrake chromium-browser
screen eyed3 htop clementine vorbis-tools cdparanoia ffmpeg
)





share|improve this answer






















  • Thank you, this wasn't what I was looking for in my question but it is helpful and I will be using this.
    – Justin Keith
    Feb 18 at 17:56














up vote
1
down vote



accepted










One way to simplify the script is to take out all the sudo calls and call the entire script with sudo



#!/bin/bash
if [[ $(id -un) != root ]]; then
echo "invoke me with sudo: sudo $0"
exit
fi

echo >> /etc/fstab
# etc


Also note that you can put newlines inside an array definition to make it more readable:



pkgs=(
autofs lame vim nfs-common handbrake-cli handbrake chromium-browser
screen eyed3 htop clementine vorbis-tools cdparanoia ffmpeg
)





share|improve this answer






















  • Thank you, this wasn't what I was looking for in my question but it is helpful and I will be using this.
    – Justin Keith
    Feb 18 at 17:56












up vote
1
down vote



accepted







up vote
1
down vote



accepted






One way to simplify the script is to take out all the sudo calls and call the entire script with sudo



#!/bin/bash
if [[ $(id -un) != root ]]; then
echo "invoke me with sudo: sudo $0"
exit
fi

echo >> /etc/fstab
# etc


Also note that you can put newlines inside an array definition to make it more readable:



pkgs=(
autofs lame vim nfs-common handbrake-cli handbrake chromium-browser
screen eyed3 htop clementine vorbis-tools cdparanoia ffmpeg
)





share|improve this answer














One way to simplify the script is to take out all the sudo calls and call the entire script with sudo



#!/bin/bash
if [[ $(id -un) != root ]]; then
echo "invoke me with sudo: sudo $0"
exit
fi

echo >> /etc/fstab
# etc


Also note that you can put newlines inside an array definition to make it more readable:



pkgs=(
autofs lame vim nfs-common handbrake-cli handbrake chromium-browser
screen eyed3 htop clementine vorbis-tools cdparanoia ffmpeg
)






share|improve this answer














share|improve this answer



share|improve this answer








answered Feb 18 at 16:41


























community wiki





glenn jackman












  • Thank you, this wasn't what I was looking for in my question but it is helpful and I will be using this.
    – Justin Keith
    Feb 18 at 17:56
















  • Thank you, this wasn't what I was looking for in my question but it is helpful and I will be using this.
    – Justin Keith
    Feb 18 at 17:56















Thank you, this wasn't what I was looking for in my question but it is helpful and I will be using this.
– Justin Keith
Feb 18 at 17:56




Thank you, this wasn't what I was looking for in my question but it is helpful and I will be using this.
– Justin Keith
Feb 18 at 17:56












up vote
2
down vote













You may use an array



pkgs=(autofs nfs-common handbrake-cli handbrake lame vim chromium-browser screen ffmpeg htop cdparanoia eyed3 vorbis-tools clementine)

sudo apt-get install "$pkgs[@]"





share|improve this answer




















  • Thank you, this answers my question. I will be updating my script to reflect this.
    – Justin Keith
    Feb 18 at 17:55














up vote
2
down vote













You may use an array



pkgs=(autofs nfs-common handbrake-cli handbrake lame vim chromium-browser screen ffmpeg htop cdparanoia eyed3 vorbis-tools clementine)

sudo apt-get install "$pkgs[@]"





share|improve this answer




















  • Thank you, this answers my question. I will be updating my script to reflect this.
    – Justin Keith
    Feb 18 at 17:55












up vote
2
down vote










up vote
2
down vote









You may use an array



pkgs=(autofs nfs-common handbrake-cli handbrake lame vim chromium-browser screen ffmpeg htop cdparanoia eyed3 vorbis-tools clementine)

sudo apt-get install "$pkgs[@]"





share|improve this answer












You may use an array



pkgs=(autofs nfs-common handbrake-cli handbrake lame vim chromium-browser screen ffmpeg htop cdparanoia eyed3 vorbis-tools clementine)

sudo apt-get install "$pkgs[@]"






share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 18 at 15:41









steeldriver

31.5k34978




31.5k34978











  • Thank you, this answers my question. I will be updating my script to reflect this.
    – Justin Keith
    Feb 18 at 17:55
















  • Thank you, this answers my question. I will be updating my script to reflect this.
    – Justin Keith
    Feb 18 at 17:55















Thank you, this answers my question. I will be updating my script to reflect this.
– Justin Keith
Feb 18 at 17:55




Thank you, this answers my question. I will be updating my script to reflect this.
– Justin Keith
Feb 18 at 17:55












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f424978%2fquick-bash-question%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)