Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am new to shell script as I do to detect the version of linux?
with shell script would detect if the version is 5 or 6 Linux with IF if possible
to execute a block of installation.
Use lsb_release -r | cut -f2 to get your distribution release version? (and cut again with a different delimiter to extract the major number of the release)
For instance:
version=`lsb_release -r | cut -f2 | cut -d. -f1`
if [ ${version} = 5 ]; then
echo "This is version 5"
elif [ ${version} = 6 ]; then
echo "This is version 6"
fi
Linux distributions and the updates people apply as well as the software they install or configure to use in place of distribution defaults vary so greatly that testing for a Linux version number is far too brittle a dependency on which to rely for an installation script. Instead, test directly for the features on which you depend and be prepared to report or install what is missing. Also, give serious thought to statically linking many of the libraries on which your code depends if you are installing compiled executables. Not every "bug fix" or "enhancement" will be compatible with your code and none of them will have been tested with it.
Related
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 19 hours ago.
Improve this question
How could I list all packages that need upgrading without the -version postfix in pacman so I can copy paste a portion for pacman -S.
Current output : acl-2.3.1-3 akonadi-22.12.2-1...etc
Required output : acl akonadi...etc
Thanks.
pacman -Qu & garuda-update; Both list versions in some form.
SOLVED:
The following command produces the required output.
checkupdates | cut -d ' ' -f1 | xargs
ps. Partial upgrades aren't recommended, use on your own discretion.
The following command produces the required output.
checkupdates | cut -d ' ' -f1 | xargs
ps. Partial upgrades aren't recommended, use on your own discretion.
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 months ago.
Improve this question
When I type echo Hello$'\n'world | cat -n I get the output as expected:
1 Hello
2 world
But if I want to number line of g++ -v | cat -n I get an unnumbered result.
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
...
What's wrong with my command?
The output of g++ -v goes to the standard error, not standard output. Redirect stderr to stdout to process it in a pipeline:
g++ -v 2>&1 | cat -n
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
This goes back to very basics, however I am confused on how.
We know yum is a repository manager that is based on rpm the package manager in RPM based systems, like Fedora.
Having said that, I thought these two commands can be used to produce the same output (in that sense I guess yum commands are the wrapper for rpm commands), however I was just proved to be wrong. Please consider the following example:
[myuser#localhost ~] yum list installed | wc -l
1627
[myuser#localhost ~] rpm -qa | wc -l
1640
These two commands produce different result, that I believed should not. I would be grateful if anyone can explain the scenario behind it.
PS: I am on Fedora 28
they don't produce exactly the same output... yum list installed also prints some headers:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* epel: ftp.nluug.nl
epel
Installed Packages
furthermore some packages can be printed on multiple lines with their version number and repository.
If you start counting those lines, then the count won't be correct. Note that the output of yum list installed also reprints output on the same line; not sure how wc deals with that...
The count of rpm -qa | wc -l however is biased also; because it contains the pubkey entries; which are not real packages.
Take a look at this answer where there are many details on these outputs: https://unix.stackexchange.com/a/330599/64031
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have many files named xxxx.min.js and want to rename the files to xxxx.js so basically want to remove .min only.
Is there a command I can use to do this job?
I thought using rename command would be easy for each single file, but that would take forever since I have many of them.
any idea?
Here's a bash-only command (not requiring Perl)
for i in *.min.js; do a=$(basename $i .min.js); echo mv $i $a.js; done
Explanation
for i in *.min.js; do
loop over all files matching *.min.js
a=$(basename $i .min.js)
extract the base name of the file (i.e. strip off .min.js) and save the result in $a
echo mv $i $a.js
for now, print to the console the command that WOULD be run if you removed the echo
When you are satisfied that it generates the correct commands, remove the echo to actually rename the files.
Ubuntu and Debian linux distribution both have a perl version of mv function called rename or prename, which supports regexp. The manual can be found here.
Go to the folder of the files and run the command as follows:
rename s/\.min\.js$/\.js/ *.min.js
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am using some tcsh code that uses a command called shuf:
shuf $file_name > out.txt
http://tuxthink.blogspot.ca/2012/06/shuf-to-shuffle-contents-of-file.html
but seems my linux/bash version does not have it. Does anyone knows a way to install it?
My linux/tcsh is:
$ echo $version
tcsh 6.14.00 (Astron) 2005-03-25 (x86_64-unknown-linux) options wide,nls,dl,al,kan,sm,rh,color,filec
$ uname -mrs
Linux 2.6.18-194.8.1.el5 x86_64
Also, I am a user of the server but I do not have super user permission, can only perform local installations in my user folder.
Thanks!
Try your package manager or sudo apt-get install shuf