date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,538,656,457,000 |
I have a tsv file of words and I want to write a bash that counts how many quartets are in the file and exports the name of the file and the number of quartets to a csv file.
For example for the file fileName.tsv: I,have,this,word,cat,home,dog,day
The result would be a csv file with fileName.tsv,2.
|
To get the number of quartets, you can count the number of words, use integer division to divide by four.
First I'd use sed 's/,/ /g' to substitute , with so that the number of words can be easily parsed. Then I'd pipe that into wc -w to count the number of words. Finally I'd use bash to perform integer division w... | Count every fourth word in a file |
1,538,656,457,000 |
Strings cmd prints the printable characters in a binary file.
what does this printable character actually mean.. I mean the code from which the binary was made was itself printable.
|
The readable code has been converted into machine code, and the comments have been removed by the preprocessor.
However, literal strings in the program like "Hello, World!" are still there for use at run-time. Also, the names of symbols like function names and variable names are contained in a table for use by debug t... | Printable characters in a binary file [closed] |
1,538,656,457,000 |
Why is this bash script read line code giving me errors?
read -p "Does this require cropping? (y/n)? " answer
case ${answer:0:1} in
y|Y )
mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:v "crop=1900:1080:-20:0" cropped/"${i%.*}.mp4"; rm -r *.mp4; cd cropped; cp -r *.mp4 ../
;;
* )
mkdir no
;;... |
You are missing the done on your for loop, so the no ) and stuff is part of the loop.
| Why is this bash script read line code giving me errors? [closed] |
1,538,656,457,000 |
I am working on macOs and tried size command on cc
$ which cc
/usr/bin/cc
it does not work correctly
$ size /usr/bin/cc
size: /usr/bin/cc: unknown load command 0x32
size: /usr/bin/cc: unknown load command 0x32
size: /usr/bin/cc: unknown load command 0x32
size: /usr/bin/cc: file format not recognized
$ size /bin/ls
s... |
It appears that you have installed GNU's size despite having the Command Line Tools package installed as you noted. Try: /Library/Developer/CommandLineTools/usr/bin/size.
If your OS is El Capitan (10.11) or later, you have to disable SIP (at least temporarily) in order to install into directories like /bin, /sbin and ... | Size command is not recognized, thought installed correctly |
1,538,656,457,000 |
I have written a shell script named startup.sh which does a lot of things (basically start a lot of things for me after turning on my local machine) - here is an excerpt:
#!/bin/bash
gnome-terminal --tab &
veracrypt --auto-mount favorites &
thunderbird &
~/Application/IDEA/bin/./idea.sh &
/usr/bin/slack &
echo myuser... |
When you start a script with '< dot> < space> < script_name>' and you have in your script "exit", your window will be closed. The dot notation means you run it within the window and then the "exit" means to exit the window, not the script itself.
Try to add >/dev/null 2>&1 to each of the line (before final &) to find ... | How to properly write and execute a shell script and exit correctly? [duplicate] |
1,538,656,457,000 |
How do I change all files (different types including .sh, .py, and other executable files) in a known directory to permission 775 without listing all of the file names?
I mean "all" of them in that directory, no exception.
UPDATED: The command below actually solved the problem for me. Any explanations why "+" instead... |
find and chmod
find path_to_dir -type f -name "*.*" -exec chmod 775 {} \;
change *.* to the type of files you would like to change its permissions. *.* will apply the changes to all files in the directory.
| chmod all files in a directory [duplicate] |
1,538,656,457,000 |
A few days ago I found the following command:
for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
As far as understand this command is going to create a symbolic link between each file using the for cycle, but what I can't really understand is the S in that numeration, what is it supposed to do?
|
Those numbers aren't randomly selected, they're the runlevels of your system. The runlevel used to determine which init scripts are run. They're mostly obsolete now. And if you're on Linux, it's highly likely that the runlevels S and 1 are the same. Your documents might be really old, or they'd probably be using updat... | Interpreting this command |
1,538,656,457,000 |
I am trying to list a number of offending IP's with a one line command, and am not sure how to do the last little bit, maybe someone can point me in the right direction.
cat /var/log/syslog* | grep "SRC=" | cut -d " " -f 14 | sort | uniq -c | sort -n -r
In English...this should print all syslog files (also those rota... |
awk '/SRC=/ { print $13 }' /var/log/syslog* | sort | uniq -c | sort -n -r | head -n 5
This does away with the catting, grepping and cutting from the original pipeline and replaces them with awk. The head -n 5 at the end will give you the top five results.
| Listing a Summary with limits |
1,538,656,457,000 |
I have tar.gz archive on external drive and to extract I need to copy to my home directory and then extract. Is there a way to have it in one go, extract to /home/me directory without the need to copy it first?
|
Use below commands:-
tar -xvzf filename.tar.gz -C /home/me
| How to extract file from tar.gz archive to different directory in bash [duplicate] |
1,538,656,457,000 |
I have a new arch install with Gnome Window Manager and Cinnamon. I created ~/.xinitrc with the command start cinnamon, and restarted the computer.
Now the system boots into the login screen for Gnome and Cinnamon, but there is no command line shell available in the GUIs, and I'm unable to boot the computer into com... |
Usually in cinnamon or gnome there is terminal application. If there is no such application, then install it.
But if you wan to get back to tty just press ctrl+alt+F1 (or any other F in range 1-6)
| Get to command line from arch cinnamon [duplicate] |
1,538,656,457,000 |
Currently my text file looks like this..
David Webb Box 34 Rural Route 2 Nixa MO 65714 (417)555-1478 555-66-7788 09-13-1970
Martha Kent 1122 North Hwy 5 Smallville KS 66789 (785)555-2322 343-55-8845 04-17-1965
Edward Nygma 443 W. Broadway Gotham City NJ 12458 (212)743-3537 785-48-5... |
It can be easily done via GNU awk by its time functions (mktime and strftime) but sed can do this too
sed '
/^[0-9]/{ #for last field with date
y|-|/|
s/^/date +"%B %d, %Y" -d /e #reformat string by date
b #go to end (print)
}
... | reformat date to have month in words |
1,538,656,457,000 |
How can I delete directories using the bash that do not contain directories named wav or mp3? I use macOS Sierra.
find . -type d \! -exec test -e '{}/wav' \; -print finds the directories not containing wav directories. How can I include mp3 to this command? And how can I delete the resulting directories?
My music libr... |
First of all, before you do this, make a backup of your files.
Seriously.
To find and remove Artist directories (and their contents, recursively) which do not directly contain directories (or files) titled either wav or mp3 (case sensitive), try the following:
find /Musik -mindepth 1 -maxdepth 1 -exec test \! -e {}/w... | bash: Deleting directories not containing given strings |
1,538,656,457,000 |
I would like to start learning Linux. Can anyone give me a sources and some tips?
|
The Linux® Command Line by William E. Shotts, Jr.
Free, well written, beginner-friendly, step-by-step, comprehensive, and with external references.
And the sooner you get used to the man pages, the better.
Also learn to read what the screen tells. Skipping output is a bad habit. If you really don't want it, learn how ... | I want to start learning Unix and Linux [closed] |
1,538,656,457,000 |
Given the /etc/passwd file, what is the command to print only the login names of users that do not have /sbin/nologin as a shell?
Also, in my /etc directory, what can I use as a command to count the # of files that start with the letter 's'? Kind of new to this, thank you!
|
To print only users that have no login shell you can use awk only in it's simplest case:
awk -F/ '$NF != "nologin"' /etc/passwd
Here we use -F/ as delimiter and then '$NF =! "nologin"' where$NFis the last field of the line/row. The default action inawk` is print so it'll print the whole line.
Finding all files starti... | Command to print users that don't have /sbin/nologin as a shell |
1,427,484,694,000 |
I have file with name --help.tgz. I want to delete but don't know how.
I tried rm "--help.tgz", rm \-\-help.tgz and it did not work. How can I delete a file with such name?
|
Try: rm -- --help.tgz
The -- tells rm that there are no further flags to process and that everything else are the files/directories to be deleted. Most unix utilities use -- in a similar way.
| delete file with name --help.tgz [duplicate] |
1,427,484,694,000 |
I want to generate a number between 0001 and 9999 on Linux, separate it into two variables, and print it like this:
I will go for 00 and 01
I'm using bash on Linux, and looking to generate this output (I assume I could use seq or echo together maybe?):
Example; from number 0001 to 0005 so the result will be like th... |
If the exercise is simply to generate that output:
seq -w 9999 | sed 's/../something something & and /'
This reads the numbers generated by seq with sed and replaces the first two digits with the text something something & and (where the & will be replaced by the two first digits). The other group of two digits wil... | generate number and devided in line for linux |
1,427,484,694,000 |
I want to convert the lowercase sequences (a,t,c,g) into '-' using the Unix command. But it's not saving the file in place. Rather it's showing errors and removing '-i' outputs in the terminal but doesn't change anything in the file. However, it outputs the desired result for the following code in the terminal but doe... |
I would use perl instead since that has the $. special variable which holds the current line number. So if $. modulo 2 is 0 (if $. % 2 == 0), then we change all occurrences of a, t, c or g to -:
$ perl -pe 's/[actg]/-/g if $. % 2 == 0' file
0 chr1 11680 11871 chr6 28206109 28206336 - 4581
----------------------------... | How can I change lowercases to '-' in the even and odd lines using sed piping? |
1,427,484,694,000 |
I am new to the terminal world and would like to process some images in a directory. Some examples of images are as follows (they are from the foggy cityscapes dataset):
frankfurt_000000_000294_leftImg8bit_foggy_beta_0.01.png
frankfurt_000000_000294_leftImg8bit_foggy_beta_0.02.png
frankfurt_000000_000294_leftImg8bit_f... |
With zsh:
autoload -Uz zmv # best in ~/.zshrc
mkmv() { mkdir -p -- $2:h && mv -- "$@"; }
zmv -n -P mkmv '(*)_leftImg8bit_foggy_beta_(*)(.png)' '$2/$1$3'
(remove the -n (dry-run) if happy).
Or with any POSIX-like shell (though without the safeguards of zmv):
for file in *_leftImg8bit_foggy_beta_*.png; do
dir=${file#... | process files and their names in a directory |
1,427,484,694,000 |
I have used the history -c command in terminal, but it only works for the open session. If I log out and back into command-window-terminal the history is still remembered. How do I stop this from occurring?
I want to manually delete the history of the typed information in the terminal, permanently, preferably just b... |
If you want to delete typed history manually, on bash shell you can delete .bash_history file or edit it to remove the lines you want removed.
To check which shell you use type echo $SHELL.
| What to do about key history being re-remembered in terminal? |
1,427,484,694,000 |
I have been trying to upload files from debian machine (raspberrypi) to mega cloud storage via CLI.
I have created the .megarc file in my home directory in the following format
[Login]
Username = ******@gmail.com
Password = ***********
I getting the following error
$ megadf -h
ERROR: Can't login to mega.nz: API call ... |
The fix I could find is as follows:-
Instead of installing and using megatools package from raspbian/debian package manager, download the installer package from https://mega.nz/cmd.
update and upgrade using:-
# apt-get update
# apt-get upgrade
Install the downloaded .deb file
# dpkg -i megacmd-Raspbian_9.0_armhf.deb
... | Upload files from raspberry pi to Mega cloud using megatools |
1,427,484,694,000 |
I decided to slim down my .zshrc and declutter oh-my-zsh entries. It seems that zsh can now auto install referenced plugins and auto update them, which was something I wanted to achieved. However, every time I run terminal I get the following output:
[zplug] Start to update 0 plugins in parallel
[zplug] Elapsed tim... |
Based on reviewing the code at https://github.com/zplug/zplug, those messages are emitted by zplug to stdout via printf, so you could silence them by changing this line:
source ~/.zplug/init.zsh && zplug update
to this one:
source ~/.zplug/init.zsh && zplug update > /dev/null
To inhibit the update altogether, simply... | Remove message shown each time ZSH runs (with oh-my-zsh installed) |
1,427,484,694,000 |
i am working on an application using delphi 7 as the front end and postgres 9.0 as the back end.
I have to upload images to the server so i use \lo_import and \lo_export for inserting images on the server and geting the images from the server.
i had come across a problem where is needed the LASTOID after a \lo_import... |
I got this answer from my question on stackoverflow postgres-9-0-linux-command-to-windows-command-conversion
Just put the commands in a file (say import.psql)
-- contents of import.psql
\lo_import '/path/to/my/file/zzz4.jpg'
UPDATE species
SET speciesimages = :LASTOID
WHERE species = 'ACAAC04';
then issue com... | Postgres 9.0 linux command to windows command conversion [closed] |
1,427,484,694,000 |
I have multiple files namely SRR3384742.Gene.out.tab SRR3384743.Gene.out.tab SRR3384744.Gene.out.tab and many more in that order. I am extracting first and fourth columns from these files and store it in an output file. I am trying to ensure that when my script reads a new file it should extract the data tab separated... |
This should give you the output described in the comments, using GNU awk:
gawk 'FNR==1{names[c++]=FILENAME}
FNR>4{ lines[$1] = "x"lines[$1] ? lines[$1]"\t"$4 : $4; }
END{
for(i=0;i<=c;i++){
printf "\t%s",names[i]
}
printf "\n";
for(i in li... | convert a new line to a tab formatted file |
1,427,484,694,000 |
I need help to find out a way to extract specific information of the lines below using Linux commands.
391,(INSIDE-A),to,(OUTSIDE-A),source,static,SRV_I_N1909,SRV_NAT_I_N1909,destination,static,REDE_AMX_MCK,REDE_AMX_MCK,translate_hits=4399,untranslate_hits=4413
431,(INSIDE-A),to,(OUTSIDE-A),source,static,WK_I_5.5.4.56... |
Assuming no field in the file has an embedded comma or newline character (i.e. it's a "simple CSV file"), you can get the first and the last two fields from each line with
$ awk -F , 'BEGIN { OFS=FS } { print $1, $(NF-1), $NF }' file.csv
391,translate_hits=4399,untranslate_hits=4413
431,translate_hits=284903,untransla... | How I can extract just some fields from a CSV line of text |
1,427,484,694,000 |
Consider the following code:
UPDATE user set password=PASSWORD('NEWPASSWORD_CAME_HERE') WHERE User='root';
Where it is written NEWPASSWORD_CAME_HERE I've putted my password (between the quote marks).
Yet when I executed this query I got this error:
ERROR 1046 (3D000): No database selected
Why have I got this error?... |
First of all, you'd have to specify the database in your UPDATE statement, not only the table:
UPDATE mysql.user ...
otherwise MySQL can't know on which database you're operating (hence the error).
However, this is not the proper way to change an user's password in MySQL. Fiddling with the mysql database (which conta... | Changing root mysql password failed when done from mysql CLI |
1,427,484,694,000 |
I am trying to build a custom kernel on ubuntu and I saw this document and it said I needed to install the packages
https://help.ubuntu.com/community/Kernel/Compile
To start, you will need to install a few packages. The exact commands to install those packages depends on which release you are using:
Hardy (8.04):
... |
Commands can be viewed with man. For example 'man sudo' would bring up documentation for the sudo command. If you are looking for information on programs like 'linux-kernel-devel' you can get that from google or from /usr/share/doc/<name> directory.
| What does the commands sudo, apt-get, install, and fakeroot stand for? [closed] |
1,427,484,694,000 |
I know there must be a way to do it, only my skills are not that sharp.
|
Create empty files
You can simply touch a find to create it and you can combine it with bash range expansion to make this easier:
touch somefile # Will create a single file called `somefile`
touch somefiles{01..10} # Will create 10 files called `somefile01` to `somefile10`
touch some{bar,baz} # Will create a file cal... | Create multiple non .txt files in a single directory without involving editors (vim, emacs, etc) [closed] |
1,427,484,694,000 |
I have a server running under Debian wheezy. I want to create a directory in /. I can't without running sudo mkdir myDirectory. Once in /myDirectory, I can't write anything or create a repertory. I tried to run as root: chmod -R /myDirectory 775, but in vain. I am sure that I am missing something obvious, but I can't ... |
Indeed, it seems that you haven't understood the basics of file permissions.
ls -ld /myDirectory shows you that root is both the owner and the group of the new directory. I.e. if you access the directory then you do that as other. And you have defined (775) that other have no write permission in this directory.
Probab... | I don't have writing access to a subdirectory in / |
1,427,484,694,000 |
find . -type f -name '*.c' -exec cat {} \; | sed '/^\s*#/d;/^\s*$/d;/^\s*\/\//d' | wc -l
Can anyone explain the meaning?
|
Explanation:
find . -type f -name '*.c' - find all files in current directory recursively with any symbols in name and .c extention. See man find
-exec cat {} \; - get content of files found on previous step. See -exec construction: -exec command {} +
sed '/^\s*#/d;/^\s*$/d;/^\s*///d' - remove several types of "commen... | This is the command to find number of lines of code that i have written? [closed] |
1,427,484,694,000 |
I want to make multiple copies of a file. I found a readily available solution and I tried. Surprisingly it did not work.
Code:
for i in {1,2,3,4}; do cp MainFile.asy 'CopyFile_$i.asy'; done
Present output:
Folder location
MainFile.asy
CopyFile_$i.asy
I am surprised where I went wrong?
More info:
Attempt1:
Attempt2... |
The problem is the single quotes which prevent $i from being expanded. Change it to this:
for i in {1,2,3,4}; do cp MainFile.asy "CopyFile_$i.asy"; done
For a more generic version that works in more shells maybe try:
for i in 1 2 3 4; do cp MainFile.asy "CopyFile_$i.asy"; done
Or this without manually entering each ... | WSL make multiple copies of a file |
1,590,319,044,000 |
Is there any way to manipulate terminal input before it gets executed? Example:
apt-get update is entered in the terminal. Now I want to change it to sudo apt-get update before it gets executed.
What I tried:
I thought about a possibility to execute a script which would then execute the entered command with the manipu... |
UH, something completely new (to me): read the answer to use PS4: how to intercept every command
If just tested:
bash: PS4='$(echo $(date) $(history 1) >> /tmp/trace.txt) TRACE: '
bash: set -x
bash: date
TRACE: date
Fr 28. Jul 14:13:24 CEST 2017
As described in the answer above, PS4 ... is evaluated for every comman... | Manipulate terminal input |
1,590,319,044,000 |
I was trying to use !! on my new install of debian and I get the following error:
$ sudo !!
sudo: !!: command not found
I do I gain use of !!?
Also what can I call !! so that I can actually google something about it?
|
You are referencing the history function of your shell when you refer to !!
I'm not sure what shell you are using. From man bash:
HISTORY EXPANSION
The shell supports a history expansion feature that is similar to the
history expansion in csh.
...
Event Designators
An event designator is a reference to a ... | How to install the '!!' command? |
1,590,319,044,000 |
Redirect the output to two different files, One should have new output whenever the commands execute and the other should have both new & old content.
For example:
openstack port create --network testnetwork1 test1-subport110 --disable-port-security --no-security-group
I need to redirect output into 2 different fil... |
cmd | tee A.txt >> B.txt
Or
cmd | tee -a B.txt > A.txt
Would tee (think of a plumber's T) cmd's output both into A.txt and in append mode into B.txt.
With the zsh shell, you can also do:
cmd > A.txt >> B.txt
(where zsh does the T'ing internally by itself when redirecting the same file descriptor several times).
To... | Redirect the output to two different files, One should have new output whenever the commands execute and the other should have both new & old content |
1,590,319,044,000 |
I have a text file containing a list of strings. The strings are separated by newlines and have the same length, 8-digit. I need to split larger file into smaller chunks, where each chunk contains 4 strings, all strings in the same sequence as they are in a large file.
So I need to create 16 files, 15 files x 4 strin... |
You can easily use split.
split --lines=4 --additional-suffix=".txt" --numeric-suffixes inputfile list
where inputfile is, obviously, the input file.
| Split text file into smaller chunks |
1,590,319,044,000 |
I need to copy a file, so that a destination file has some specific string on beginning of each line, and it needs to be a bash one liner. So no script and loops, just bol.
bol - bash one liner
I personally need this done with command that uses grep program. I appreciate if you can solve it any way possible, I just do... |
$ sed 's/^/specific string/' input >output
You said you needed to use grep, okay...
$ sed 's/^/specific string/' input | grep . >output
| How to copy the file while making changes to every line [bol]? |
1,590,319,044,000 |
If I have typed in Service apache and service tomcat for example,
how do I switch to previously written stuff?
|
You can use the Page up/Page down keys.
| How can I autocomplete a console line I wrote before? |
1,590,319,044,000 |
I have these files in MAC which have weird ._ character before filenames/folders. Which I want to delete in one shot. Is there a way to do it in commandline?
eg.
._js
._css
._image
if I go into normal image folder. I see another swarm of these files along with the actual files.
|
In bash, this will delete everything in the current working directory which has the prefix ._:
rm ._*
If what you actually wanted to do was change their names to a form without the prefix, you can run:
ls ._* | while read line
do
mv -- "$line" "${line:2}"
done
| how to delete swarm of ._ files using commandline |
1,590,319,044,000 |
There are multiple .tar files in a directory. I am trying to extract them all.
The following command works
for a in $(ls -1 *.tar); do tar -xvf $a; done
But when I try following command, it prints all the file names but does nothing. It does not extract the .tar files.
% tar -xvf *.tar
Solarized-Dark-Cyan-3.0.3.tar
S... |
unzip handles '*.zip'-style arguments, tar doesn’t. There might be archive extractors with this feature, with the ability to extract tarballs, but I’m not aware of any.
You should avoid using ls for this:
for a in *.tar; do tar -xvf "$a"; done
tar -xvf *.tar tries to extract the second and further tarballs from the f... | Untar multiple files in a directory |
1,590,319,044,000 |
I have a massive file of customer account information that is currently sorted like this, into one column. I am looking to split each row, using the : as the separator. But in doing so, for each row, when separated, I wanted to make into a new column, placing the data after each : into the respective column. My ultima... |
Using perl, which is present on any desktop or server Linux distro:
perl -lne '
BEGIN{$,=","}
($k,$v)=split":",$_,2;
next unless defined $v;
for($k,$v){s/"/""/g,$_=qq{"$_"}if/[$,"]/}
$k=$t{$k}//=$t++;
if(exists$f[$k]){print@f;@f=()}
$f[$k]=$v;
END{print@f;print STDERR sort{$t{$a}<=>$t{$b}}keys%... | Using sed, awk, or tr to split each row, using colon (:) as the separator, into CSV format |
1,590,319,044,000 |
I have a file containing space for example like this:
ACTTTTTTTTGSGSGSGSG TTT
RTATATTATRSSTSTSTST HHH
I want to eliminate the space and get the result:
ACTTTTTTTTGSGSGSGSG__TTT
RTATATTATRSSTSTSTST__HHH
|
With sed, assuming that the purpose is to replace each blank space with an underscore (_), for all blanks spaces in the lines
sed 's/ /_/g' file
Tests
$ cat file
ACTTTTTTTTGSGSGSGSG TTT
RTATATTATRSSTSTSTST HHH
$ sed 's/ /_/g' file
ACTTTTTTTTGSGSGSGSG__TTT
RTATATTATRSSTSTSTST__HHH
| How to replace space by __ |
1,590,319,044,000 |
I came across the command
du -xh / | grep -P "G\t"
I am interested in the switch -P of grep and what does it do. Also, can anyone explain what the "G\t" part does?
Please do not explain du -xh or the basics of the command grep.
$ du -xh / | grep -P "G\t"
5.1G /var/oracle/XE/datafile
5.1G /var/oracle/XE
5.1G ... |
As explained in the grep manual, -P enables the use of PCREs, i.e. Perl Compatible Regular Expressions.
The PCRE expression G\t matches a G followed by a tab.
The effect is that you only get a listing of directories whose size is listed in gigabytes (or whose name happens to match the pattern).
An alternative pipeline... | Command du -xh / | grep -P "G\t" explained? |
1,590,319,044,000 |
I have this script
#!/bin/bash
module load bedtools/2.21.0
bamfiles=(
/temp/hgig/fi1d18/1672_WTSI-COLO_023_1pre/mapped_sample/HUMAN_1000Genomes_hs37d5_RNA_seq_WTSI-COLO_023_1pre.dupmarked.bam
/temp/hgig/fi1d18/1672_WTSI-OESO_005_w3/mapped_sample/HUMAN_1000Genomes_hs37d5_RNA_seq_WTSI-OESO_005_w3.dupmarked.bam
/temp/h... |
Given the limited information in your question, and assuming your bamtofastq command is this one from the bedtools package, I have come up with the following:
#!/bin/bash
bamfiles=(
/path/to/file1.bam
/path/to/file2.bam
/path/to/file3.bam
)
for file in "${bamfiles[@]}"; do
fname=$(basename "$file")
... | Running a pipelin in linux [closed] |
1,590,319,044,000 |
I have a log file like
name = CE_20_122 assigned_hostnames = host1 cpuset_name = usr_1397032
name = CE_21_122 assigned_hostnames = host4 cpuset_name = usr_1397028
name = CE_22_122 assigned_hostnames = host4 cpuset_name = usr_1397024
.
.
.
name = CE_76_122 assigned_hostnames = host27 cpuset_name = usr_1397012
na... |
by hostX:
sort -nk 6.6
by usr_X
sort -nk 9.6
| text file sorting |
1,590,319,044,000 |
When I execute man foo the terminal shows only the first page and then pauses. Then I have to manually press the keys to scroll here and there.
After executing man foo how do I get an output which is continuously scrolling till the end of it. It'll be bonus if I could control the speed of scrolling.
|
man itself does only call $PAGER to display the man page. $PAGER is usually set to less, which does not support such kind of scrolling.
You can simply set $PAGER to any other command that does support such a feature.
You can also simply do something like:
man man|perl -pe 'sleep 1'
Of course you can also make it slee... | Auto continuous scrolling of man output |
1,590,319,044,000 |
I'm having an interesting issue with XFCE Terminal/Gnome Terminal (not reproducible in XTerm), where executing bash or logging in using login or su will open a new Bash instance inside a Bash instance as shown:
_randall@manbearpig:/home/randall[root@manbearpig randall]#
Ctrl+D and exit both exit back to the original b... |
I don't understand the problem. typing bash, login or su are SUPPOSED to start a new shell.
What is it that you expect to happen?
I cannot see where your system is doing anything wrong.
if you want to open another TERMINAL program, then type gnome-terminal or whatever the program name is.
Bash is a shell, where you ty... | Duplicate bash prompts |
1,590,319,044,000 |
I would like to edit something like this;
ABC
abc
123
Into something like this;
Aa1Bb2Cc3
|
Asumming the string are exactly 3 characters long you can do it with awk for example. Something like do the work:
awk 'BEGIN {FS="" } {a=a$1;b=b$2;c=c$3} END {print a b c}' input_file >output_file
If the length is different and constant over the lines you can use something like:
awk -v N=3 'BEGIN {FS="" } { for(i=1;... | How to convert multiple columns from file to single string |
1,590,319,044,000 |
I have a huge .csv file in this format:
"acc","lineage"
"MT993865","B.1.509"
"MW483477","B.1.402"
"MW517757","B.1.2"
"MW517758","B.1.2"
"MW592770","B.1.564"
...
i.e, the first column is a string representing the accession_id of the data sample and the second column is a covid variant lineage. I would like to extract ... |
Method 1
Since the string in your .csv is always between double-quotes ", you could include the quotes in your match. You then simply use single quotes ' for the expression.
Example:
asdf.csv:
"foo","B.1.1.529"
"bar","B.1.1.529.1"
╰─$ grep '"B.1.1.529"' ./asdf
"foo","B.1.1.529"
As you see B.1.1.529.1 will not match... | grep to find an exact word match with a period in it |
1,590,319,044,000 |
Is there any way to search a string after given match ?
e.g. If I run dmidecode then it will give a lot of information. e.g.
BIOS Information
Vendor: ABCD
Version: 123456(V1.01)
Release Date: 01/01/1970
Address: 0xE0000
Runtime Size: 128 kB
ROM Size: 8192 kB
Characteristics:
PCI is ... |
$ sudo dmidecode |
awk '/^BIOS/ { ++Bios } Bios && /Version/ { print; exit; }'
Version: 02PI.M505.20110824.LEO
$
We just count that BIOS went past, and trigger on the Version line.
As the BIOS is the first block (on my system), and grep has a max-count option, this should also work
sudo dmidecode | grep -m 1... | Search a string after a match |
1,590,319,044,000 |
My current directory contains two directories test1 and test2.file1 is present in test1.
How can I create symbolic link in folder test2/lin for file1?
After the link operation Link file in test2/lin should point to test1/file1
|
The symlink resolution by the system is relative to the target (unless the link is absolute of course).
So it has to be considered as if you went into the final directory. In this case that would be (with explicit naming of the target):
cd test2/lin
ln -s ../../test1/file1 file1
The source doesn't change, that's the ... | How to link file in subdirectory to another subdirectory in shell script |
1,590,319,044,000 |
I want to apply diff to compare to directory recursively and store it output in c.txt \n
when I use diff -qr dir1 dir2 >c.txt It store something like Files dir1/a.txt and dir2/a.txt differ. But I want to store only a in it. Any suggestion
|
Looks like you need to compare only files with the same name. diff exits with code 1 if files are different and with 0 otherwise.
for f in dir1/*
do
b = `basename $f`
[[ -f dir2/$b ]] && [[ diff -q $f dir2/$b ]] && echo $b >> c.txt
done
It's easier than to process diff output.
| diff to store only file name in another file |
1,590,319,044,000 |
echo INPUT | MAGIC > OUTPUT
INPUT: a random number that can be 0-999999999999 (so very big)
OUTPUT: a number between: 0-1023
MAGIC: a solution where the random smaller/bigger input is "converted" to the interval that the OUTPUT uses, so 0-1023
example:
INPUT: 0
OUTPUT: 0
another example:
INPUT: 1634
OUTPUT: 609
I... |
echo Enter the INPUT:
read INPUT
echo OUTPUT: $(echo "$INPUT % 1024" | bc)
| Generate between interval while having overflow |
1,590,319,044,000 |
To expand on my previous question, I have another pattern of a file, I am trying to change the name of first column ranging from seq1 to seq20 (seq1-seq20) as seq1 similarly ranging from seq21 to seq60 (seq21-seq60)as seq2. File name is file.txt anf the following format is:
seq22 19301 20914 fill_color=green_a0
seq5... |
I suggest:
awk '{gsub(/[^0-9]/,"",$1); if($1+0<21){$1="seq1"} else {$1="seq2"}; print}' file
gsub(/[^0-9]/,"",$1) removes all but numbers from first column.
| Renaming object or element in perticular range in a column of text file |
1,667,644,510,000 |
please, help for this commande. so I write this commande
awk -F":" '{tab[$5]+=1} END { for (i in tab) {print i,tab[i]}}' AnnuaireBis.txt
who give this output:
Ketou 4
Anneho 4
Panhouignan 4
Bohicon 2
Kpedekpo 2
but I want to get this format:
Please, help me. Thank you so much
|
you don't even need to put both elements inside the s/printf portion :
mawk -F':' '$!_=sprintf("%-15s",$!_)'
Ketou 4
Anneho 4
Panhouignan 4
Bohicon 2
Kpedekpo 2
Confirmed to work for gawk, mawk-1, mawk-2, and nawk
| awk commande-line [closed] |
1,667,644,510,000 |
I have a problem that I think sed is probably perfect for, but I don't know enough about it to figure out how to employ it correctly.
Here's what I have - a file like this, but much longer:
https://www.npmjs.com
https://www.npmjs.com/package/rabin
https://www.politico.com/news/magazine/blah/blah
https://www.raspberryp... |
This did the trick:
cat input.txt | \
gawk -e '{match($0, /(https?:\/\/(?:www.)?[a-zA-Z0-9-]+?[a-z0-9.]+)/, url)} \
!a[url[1]]++{ \
b[++count]=url[1] \
} \
{ \
c[url[1]]=$0 \
} \
END{ \
for(i=1;i<=count;i++){ \
print c[b[i]] \
} \
}' > output.txt
The regular expression could probably be simpli... | Remove all URLs in a series with the same domain except the last occurrence, in a long list of many URL series |
1,667,644,510,000 |
I attached both picture and *.txt file https://1drv.ms/t/s!Aoomvi55MLAQh1jODfUxa-xurns_ of a sample work file. In this file Reactions which only start with "r1f", "r2f", "r3f"......and so on. And for each reaction the reaction rates is situated couple of lines later with a "+" sign.
I want to change the first An... |
How about this .... definitely a sledgehammer.
Invoke it as thisScript Prob01.txt 0.75 0.25 to apply combinations of +/-75% change on the 1st and +/-25% on the 3rd values on each reaction and write them to separate files
#!/bin/bash
#takes $inputFile $pct1 $pct3
#note $pct is the multiplier expressed as a decimal
#gl... | How to manipulate numbers in a file"? [closed] |
1,667,644,510,000 |
Suppose I have 100 texts under the same dir, i.e., text1.txt, text2.txt,...,text100.txt. I want to extract certain lines(e.g., first 100 lines)from each text, and save the lines to another new 100 texts respectively,that is, each new text has 100 lines.
I know head -100 text1.txt > text1_new.txt, head -100 text2.txt >... |
One way would be
find . -name "text*.txt" -type f -print0 | xargs -0 -I{} sh -c 'f="{}"; head -100 "$f" > "${f%.txt}_new.txt"'
find . -name "text*.txt" -type f finds all text files in the directory
-print0 prints the file path with a null character to preserve spaces
xargs -0 takes the null terminated arguments
-I{... | How to obtain certain lines from several texts simultaneously? |
1,667,644,510,000 |
I have a directory that has several subdirectories in it. Each subdirectory has several files in it. I want to delete all the files in the subdirectories except the .pdf ones. And leave the subdirectories alone. I used
find . -type f ! -iname "*.pdf" -delete
But I have to be in the subdirectory to make it work. I w... |
In bash, to delete all of the non-pdf files in all of the subdirectories of the current one:
shopt -s extglob
rm */!(*.pdf)
The initial */ matches every subdirectory, and the extglob option enables the !( ... ) pattern that says: match all files except what's inside the parenthesis; in this case, the pattern to exclu... | Removing certain files in a series of subdirectories |
1,667,644,510,000 |
How can I associate one public IP address per Namespace in my Ubuntu 14.04 server? I need to launch one specific process per Namespace then per public IP address.
I want to do that:
configuration:
nameSpace1 use: publicIP1
nameSpace2 use: publicIP2
nameSpace3 use: publicIP3
Terminal:
nameSpace1 ffmpeg etc...
nameSpa... |
Partial answer, based on some assumptions that may not be true:
In general, network namespaces provide control over what network interface is visible to what processes. Assigning a network namespace to an interface will make sure it's only seen by processes running in that namespace. Conversely, processes running in t... | One public IP address per Namespace [closed] |
1,667,644,510,000 |
For instance, consider the following example. I have a process running on my machine and I only want a specific string in my output.
When I run the following command
ps -ef | grep pmon
I get
oracle 3680 1 0 Oct04 ? 00:00:08 ora_pmon_SEED
I want the command to only display "SEED"
SEED
|
In that specific example you could pipe it through to cut:
ps -ef | grep pmon | cut -d _ -f 3
Why you would want to, however, is a bit of a mystery.
| How do I get a specific string using ps command in linux [closed] |
1,667,644,510,000 |
I have a directory with several duplicate files, created by a program. The duplicates have the same name (except for a number), but not all files with the same name are duplicates.
What's a simple command to delete the duplicates (ideally a single line limited to GNU coreutils, unlike the question about scripts)?
Exa... |
A quick and dirty solution is to hash the files, then search the hashes which appear more than once and delete those whose filename is numbered.
For instance:
sha1sum * > files.sha1sum
cat files.sha1sum | cut -f1 -d" " | sort | uniq -c | grep -v " 1 " | sed --regexp-extended 's/^[^0-9]+[0-9] //g' | xargs -n1 -I§ grep... | Command to delete duplicate files from current directory [duplicate] |
1,667,644,510,000 |
I piped one echo command into the other
üåê echo a b c d e f g h i | echo
üåê echo $?
0
Contrary to my intuition, there was no output, however there was also no error returned. I expected, that echo a b c d | echo is only an unnecessary redundant alternative to echo a b c d .
But it is not the case, Why were t... |
This is due to echo not reading from standard input. Pipes are only useful for sending the standard output from one command to the standard input of the next command.
Since the output ef echo a b c ... is not consumed by the second echo, it is lost and there is no output from the pipe, except for the single newline f... | Why does "echo a b c d e | echo" display no result? [duplicate] |
1,667,644,510,000 |
So I have tried over 10 different attempts and I'm just stumped
Here are two inverted-tree diagrams. Issue a command to change the left diagram to the right diagram. Assume that you are in your home directory and use relative pathnames. [home] is your home directory:
Here is the diagram:
[home] ... |
You want to move the systems directory into the courses directory. Just:
mv systems courses/
| What command would I issue in order to complete this question? |
1,667,644,510,000 |
I have trouble executing binary file, both from the GUI and the command line. I am running Ubuntu 17.10 . Here are the logs :
julien@julien-PC:~/JEUX/ROMS/Logiciels/snes9x-1.53$ ls
data docs snes9x-gtk
julien@julien-PC:~/JEUX/ROMS/Logiciels/snes9x-1.53$ ./snes9x-gtk
bash: ./snes9x-gtk: Aucun fichier ou dossier de ... |
These are 32-bit binaries; to get them running on your Ubuntu system, you need to install :i386 packages. The i386 architecture should already be enabled, but just in case, run
sudo dpkg --add-architecture i386
sudo apt update
Then install the missing libraries, e.g.
sudo apt install libx11-6:i386 zlib1g:i386
etc. T... | Can not execute binary file on Ubuntu 17.10 [closed] |
1,667,644,510,000 |
I want to login in remote server and I don't know the remote server password. I am doing the below command
cat id_rsa.pub | ssh [email protected] | cat > authorized_keys
or
scp id_rsa.pub [email protected]:~./ssh/authorized_keys
But it asking for password
|
There is no possible way to access to server and put or edit anything without any authentication, because in the end you are trying to edit authorized_keys file, and if there is no authentication you could copy and paste any thing you want to that file and that will be a horrible security vulnerability
| How to copy the id_rsa.pub keys in remote server authorized_key without knowing the remote server password [closed] |
1,667,644,510,000 |
The command:
mount -t cifs -o username=root //ipadress/map/mnt/map
So I mean like what does "mount" mean? What does "-t" mean? Etc.
|
Whenever you are wondering what a command means, the first step is to run man command (where "command" is the command in question, so man mount in this case). That will bring up the command's manual which usually includes a short description of what it does and also an explanation of the various options. Admittedly, t... | What does every part of the "mount -t cifs -o username=root //ipadress/map/mnt/map" command mean? [closed] |
1,667,644,510,000 |
I have a simple text file named as 'file.txt'
I want to create a .zip file which only include that 'file.txt'.
I tried cat file.txt | zip newZipFun.zip -@. But it compressed my parent folder.
Additionally I need to output my .zip to a different location too.
|
If you can't just do zip newZipFun.zip file.txt as larsks suggested, you can imagine doing
find . -name "toto*" | xargs zip totos.zip
where "toto*" is the name of all files starting with toto, in the current working directory and it's sub directories
| txt file to zip file |
1,667,644,510,000 |
hieupa@cpt00108094a:/media$ ll
total 16
drwxr-xr-x 4 root root 4096 Th04 4 13:47 ./
drwxr-xr-x 24 root root 4096 Th04 4 09:29 ../
drwxrwxrwx+ 3 hieupa hieupa 4096 Th04 4 13:47 hieupa/
drwxr-x---+ 2 root root 4096 Th04 4 13:45 hieupalocal/
I have just created an user hieupa, but it not have permis... |
If you just want the directory permissions changed:
sudo chown heiupa:heiupa hieupa
If you want it to be recursive, affecting all the files within, run this instead:
sudo chown -R heiupa:heiupa hieupa
To delete the entire directory hieupalocal including the contents.
sudo rm -r hieupalocal
If you are prompted on wh... | How to set root permissions for one directory and delete another? |
1,667,644,510,000 |
Where does Linux keep the list of valid commands that can be called from the command prompt (using ENTER key after command is typed)?
Is this list exhaustive or are there ways to type other things at the command prompt that are NOT in this list; and if so, what are they? (ie: CTRL+C -- to break from the command pr... |
Nowhere.
Linux is the kernel, and just the kernel. Any commands are either shell built-ins, which are listed in the documentation of each shell, or executable binaries located usually in /bin and /sbin directories in the /, /usr and /usr/local. Shells themselves are also binaries located in those directories.
There ar... | Exhaustive list of Linux commands for command prompt [closed] |
1,667,644,510,000 |
Why is there no summary option in coreutils ls command, like MS-DOS/Windows has?
With summary option I mean:
count the files and dirs and sum up their sizes.
Update:
It should read: "Even DOS/Windows has one."
It's:
command.com vs. sh
cmd.exe vs. bash
with clear points for the latters.
But for some reason, an... |
But the basic functions should be provided by the tool itself.
This is correct. The UNIX/Linux philosophy is to have commands/tools that do one thing only, and do that thing extremely well. Then the stdout of one command is fed to the stdin of another, via a pipe, to produce complex results.
The purpose of the ls co... | coreutils ls summary |
1,667,644,510,000 |
I ran this command on Fedora, which I anyway wanted to uninstall, so I decided to check out this command: sudo rm -rf /* just for fun. As soon as I ran this command, the GUI stopped working and patches of black started appearing, I thought the work was done, and did a forced shutdown.
[By the way, I was multibooting W... |
sudo rm -rf /* (-r means to remove directories and their contents recursively and -f to ignore nonexistent files and arguments and never prompt for confirmation and /* just expands to everything in /) removes everything in / and as you found out with /boot/efi this also includes mounted filesystems. The reasons why so... | What does ' sudo rm -rf /* ' do? |
1,667,644,510,000 |
Suppose I have 4 directories :
Directory_1 Directory_2 Directory_3 Directory_4
Is there a command line in a terminal Linux I can use to copy a file to all of these directories?
Is there a command line in a terminal Linux I can use to remove a file to all of these directories in the same time?
|
Is there a command line in a terminal Linux I can use to copy a file to all of these directories?
Yes, but it's not something obvious to a beginner
tee Directory_{1..4}/file <file >/dev/null
Another approach is to use four separate commands
cp file Directory_1
cp file Directory_2
cp file Directory_3
cp file Directo... | Remove or copy a file all at once |
1,667,644,510,000 |
I tried to find info online, but I could not find any. It seems that many people use a specific sequence of numbers, without actually providing any explanation why.
More specifically, my $PS1 in bash is the following:
\[\033[38;5;21m\][\[\033[38;5;20m\]\u@\[\033[38;5;1m\]\h \W\[\033[38;5;21m\]]\[\033[0m\]\$
I canno... |
Originally the codes came from DEC as part of their VT52/VT100/VT220 series serial display consoles. These were later standardised as part of ECMA and ANSI, and over time extended.
You can see one such early ECMA standards document from 1979, specifically page 40 of the document (page 48 of the PDF file) section 7.2.6... | What is the 38;5 sequence in $PS1? |
1,667,644,510,000 |
This is actually for brew search
but to simplify, let's say I do:
echo -e 'somedir\n\otherdir'
somedir
otherdir
Can I use otherdir as an argument without doing this?
ls $(echo -e 'somedir\n\otherdir |tail -n1)
otherdir
Update to Clarify Goal
To be more clear somedir and otherdir go to stdout, can I run a command on... |
You can always use xargs which is intended for this kind of thing: convert output streams to list of arguments:
printf 'somedir\n\otherdir\n' |
tail -n1 |
xargs -rd '\n' ls -l --
Beware -d '\n', needed here for arguments to be expected as lines requires the GNU implementation of xargs.
If that last line doesn't c... | how to to execute a command output as an argument without saving it using $()? |
1,519,164,598,000 |
What does the -d mean in the below?
sed 's/^ *//' < /tmp/list.txt | xargs -d '\n' mv -t /app/dest/
|
From man xargs:
--delimiter=delim
-d delim
Input items are terminated by the specified character. Quotes and
backslash are not special every character in the input is taken
literally. Disables the end-of-file string, which is treated like
any other argument. This can be used when the input consists of
sim... | What does the "-d" stand for in xargs -d [closed] |
1,519,164,598,000 |
When I run the mkdir {2009..2011}-{1..12} command, why can not I see it consecutively like 2009-1 2009-2 2009-3 ... 2009-12?
|
The listing is sorted lexically in columns. So 12 comes before 2 because it sorts on the first digit (as if it were a word with ab coming before b in standard sorting) and 1 comes before 2.
The normal way to handle this would be to include a leading zero on the single digits. 2009-01, 2009-02, ..., 2009-09, 2009-10. ... | Why can not I see the screen output consecutively? |
1,519,164,598,000 |
I want to move files from parent directory to sub-directory using command only. because i have only SSH access to remote server.
I have files on /var/www/html/ and i want to move to /var/www/html/myfolder
UPDATE: i somehow followed these steps was able to move files.
Check this Answer
|
Ok, I'll bite. You use the mv command.
Say that you are in directory foo:
ls foo/*
foo/file1 foo/file2
foo/bar:
Now you want to move file1 and file2 from directory foo to directory foo/bar:
mv -v file1 file2 bar/
file1 -> bar/file1
file2 -> bar/file2
Result:
ls foo
bar
ls foo/bar/
file1 file2
https://www.linux.com... | How to move files from parent diretory to sub-directory using command? [duplicate] |
1,519,164,598,000 |
How are apps like vim and w3m built? I was trying to find info about this online but I couldn’t really find much.
|
You could check the project's source code repositories. For instance, the vim source code can be found at: https://github.com/vim/vim
However, you probably want to start a few steps earlier, as such large and grown projects tend to be very complicated.
But I don't think this was your intended question. I assume you ar... | How to make CLI applications in Unix? [closed] |
1,519,164,598,000 |
I am new to UNIX.
How do I achieve the below
input: text1=ABC/text2=DEF
output: text1,text2
Thanks
|
Your question is not very exact in term of structure of the string you would like to convert. So I'm going to guess that your input characteristics are:
Multiple KEY=VALUE pairs are provided in single line.
Each pair will be separated from other pairs by / character.
/ must be placed only between pairs (not at the st... | find a string and get the previous string delimited by a comma [closed] |
1,519,164,598,000 |
I understand what the "cat" command does.
I.e.
cat file1 file2 > file3
Will put the contents of file1 and file2 in file3. (If I am not mistaken)
But what exactly does:
cat file1 | file2 > file3
do?
I don't have a UNIX machine to test this on, and I can't google " | ", hence my question.
|
It's a pipeline. It will redirect the standard output of the first command into the standard input of the second command.
cat file1 | grep example
For example, the above command will catenate the requested file into grep's stdin.
The command you posted would fail.
cat file1 | file2 > file3
file2 isn't an executable... | What does "|" between arguments in cat command do? |
1,519,164,598,000 |
I would like to create a new .wc command.
|
With the exception of shell builtins, commands are just programs. This means your question reduces to, "How do I write a program?"
(Or, "How do I write a script?" which amounts to the same thing, since a script is just another type of program. The distinction between scripting and programming is not important to get i... | How to create new script , role like wc [closed] |
1,519,164,598,000 |
I googled this question many times but could not find a good reason why the knowledge of command line is important.Some say GUI cannot be used always but there are no examples supporting their statement.
|
On command line you need to learn a few comparatively low level but extremely flexible tools, which serve as building blocks for anything more complex. You only need to learn them once and you can combine them later for any task you need to do.
GUI-based tools tend to be more powerful, but also tend to be more special... | Why is learning command line imporatant? [duplicate] |
1,519,164,598,000 |
I have a couple of questions about the find command.
How to show how many files and directories(only the result numbers) within the /var directory (and below) are owned by someone other than you or root.
same as above, but this time is to show how many users.
Modify the command to show those other owners (in alphabe... |
Have I already mentioned I like zsh's glob qualifiers?
files_in_var_not_owned_by_me_or_root=(/var/**/*(^u0u$UID))
echo $#files_in_var_not_owned_by_me_or_root
typeset -U owners_of_files_in_var
zstat -s -A owners_of_files_in_var +uid -- $files_in_var_not_owned_by_me_or_root
echo $#owners_of_files_in_var
i=1
for x in $... | Find Command: display the file numbers [closed] |
1,349,361,022,000 |
So I was surfing the net and stumbled upon this article. It basically states that FreeBSD, starting from Version 10 and above will deprecate GCC in favor of Clang/LLVM.
From what I have seen around the net so far, Clang/LLVM is a fairly ambitious project, but in terms of reliability it can not match GCC.
Are there an... |
Summary: The primary reason for switching from GCC to Clang is the incompatibility of GCC's GPL v3 license with the goals of the FreeBSD project. There are also political issues to do with corporate investment, as well as user base requirements. Finally, there are expected technical advantages to do with standards com... | Why is FreeBSD deprecating GCC in favor of Clang/LLVM? |
1,349,361,022,000 |
I understand how to define include shared objects at linking/compile time. However, I still wonder how do executables look for the shared object (*.so libraries) at execution time.
For instance, my app a.out calls functions defined in the lib.so library. After compiling, I move lib.so to a new directory in my $HOME.
H... |
The shared library HOWTO explains most of the mechanisms involved, and the dynamic loader manual goes into more detail. Each unix variant has its own way, but most use the same executable format (ELF) and have similar dynamic linkers¹ (derived from Solaris). Below I'll summarize the common behavior with a focus on Lin... | Where do executables look for shared objects at runtime? |
1,349,361,022,000 |
What is the Fedora equivalent of the Debian build-essential package?
|
The closest equivalent would probably be to install the below packages:
sudo dnf install make automake gcc gcc-c++ kernel-devel
However, if you don't care about exact equivalence and are ok with pulling in a lot of packages you can install all the development tools and libraries with the below command.
sudo dnf group... | What is the Fedora equivalent of the Debian build-essential package? |
1,349,361,022,000 |
I need to compile some software on my Fedora machine. Where's the best place to put it so not to interfere with the packaged software?
|
Rule of thumb, at least on Debian-flavoured systems:
/usr/local for stuff which is "system-wide"—i.e. /usr/local tends to be in a distro's default $PATH, and follows a standard UNIX directory hierarchy with /usr/local/bin, /usr/local/lib, etc.
/opt for stuff you don't trust to make system-wide, with per-app prefixes—... | Where should I put software I compile myself? |
1,349,361,022,000 |
What benefit could I see by compiling a Linux kernel myself? Is there some efficiency you could create by customizing it to your hardware?
|
In my mind, the only benefit you really get from compiling your own linux kernel is:
You learn how to compile your own linux kernel.
It's not something you need to do for more speed / memory / xxx whatever. It is a valuable thing to do if that's the stage you feel you are at in your development. If you want to have ... | What is the benefit of compiling your own linux kernel? |
1,349,361,022,000 |
Will the executable of a small, extremely simple program, such as the one shown below, that is compiled on one flavor of Linux run on a different flavor? Or would it need to be recompiled?
Does machine architecture matter in a case such as this?
int main()
{
return (99);
}
|
It depends. Something compiled for IA-32 (Intel 32-bit) may run on amd64 as Linux on Intel retains backwards compatibility with 32-bit applications (with suitable software installed). Here's your code compiled on RedHat 7.3 32-bit system (circa 2002, gcc version 2.96) and then the binary copied over to and run on a Ce... | Will a Linux executable compiled on one "flavor" of Linux run on a different one? |
1,349,361,022,000 |
I want to install tmux on a machine where I don't have root access. I already compiled libevent and installed it in $HOME/.bin-libevent and now I want to compile tmux, but configure always ends with configure: error: "libevent not found", even though I tried to point to the libevent directory in the Makefile.am by mod... |
Try:
DIR="$HOME/.bin-libevent"
./configure CFLAGS="-I$DIR/include" LDFLAGS="-L$DIR/lib"
(I'm sure there must be a better way to configure library paths with autoconf. Usually there is a --with-libevent=dir option. But here, it seems there is no such option.)
| Why can't gcc find libevent when building tmux from source? |
1,349,361,022,000 |
I was wondering: when installing something, there's an easy way of double clicking an install executable file, and on the other hand, there is a way of building it from source.
The latter one, downloading a source bundle, is really cumbersome.
But what is the fundamental difference between these two methods?
|
All software are programs, which are also called source packages. So all source packages need to be built first, to run on your system.
The binary packages are one that are already build from source by someone with general features and parameters provided in the software so that a large number of users can install and... | What is the difference between building from source and using an install package? |
1,349,361,022,000 |
I wish to install OpenVPN on OpenBSD 5.5 using OpenVPN source tarball.
According to the instructions here, I have to install lzo and
add CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"
directives to "configure", since gcc will not find them otherwise.
I have googled extensively for guide on how to do the... |
The correct way is:
./configure CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"
but this may not work with all configure scripts. It's probably better to set environment variables such as CPATH and LIBRARY_PATH (see gcc man page).
An example:
export CPATH=/usr/local/include
export LIBRARY_PATH=/usr/local/lib... | What is the correct syntax to add CFLAGS and LDFLAGS to "configure"? |
1,349,361,022,000 |
Let's say I work for a large services organisation outside the US/UK. We use UNIX and Linux servers extensively.
Reading through this article it mentions that it would be easy to insert a backdoor into a C compiler, then any code compiled with that compiler would also contain a backdoor. Now given recent leaks regardi... |
AFAIK the only way to be completely sure of security would be to write a compiler in assembly language (or modifying the disk directly yourself). Only then can you ensure that your compiler isn't inserting a backdoor - this works because you're actually eliminating the compiler completely.
From there, you may use your... | How to compile the C compiler from scratch, then compile Unix/Linux from scratch |
1,349,361,022,000 |
./configure always checks whether the build environment is sane...
I can't help but wonder what exactly a insane build environment is. What errors can this check raise?
|
This comes from automake, specifically from its AM_SANITY_CHECK macro, which is called from AM_INIT_AUTOMAKE, which is normally called early in configure.ac. The gist of this macro is:
Check that the path to the source directory doesn't contain certain “unsafe” characters which can be hard to properly include in shel... | ./configure: What is an insane build environment? |
1,349,361,022,000 |
This is an issue that really limits my enjoyment of Linux. If the application isn't on a repository or if it doesn't have an installer script, then I really struggle where and how to install an application from source.
Comparatively to Windows, it's easy. You're (pretty much) required to use an installer application t... |
Normally, the project will have a website with instructions for how to build and install it. Google for that first.
For the most part you will do either:
Download a tarball (tar.gz or tar.bz2 file), which is a release of a specific version of the source code
Extract the tarball with a command like tar zxvf myapp.tar.... | How to compile and install programs from source |
1,349,361,022,000 |
I'm trying to install a Debian package from source (via git). I downloaded the
package, changed to the package’s directory and ran ./configure command but
it returned bash: ./configure: No such file or directory. What can be the
problem? A configure.ac file is located in the program folder.
./configure
make
sudo make ... |
If the file is called configure.ac,
do $> autoconf
Depends:
M4, Automake
If you're not sure what to do,
try $> cat readme
They must mean that you use "autoconf" to generate an executable "configure" file.
So the order is:
$> autoconf
$> ./configure
$> make
$> make install
| Can not run configure command: "No such file or directory" |
1,349,361,022,000 |
I am trying to upgrade apache 2.2.15 to 2.2.27. While running config.nice taken from apache2.2.15/build I am getting following error:
checking whether the C compiler works... no
configure: error: in `/home/vkuser/httpd-2.2.27/srclib/apr':
configure: error: C compiler cannot create executables
I have tried to search o... |
From the output you've given, you are trying to compile a 32-bit build of apache on a 64 bit system. This is from the intput to configure here:
--host=x86_32-unknown-linux-gnu host_alias=x86_32-unknown-linux-gnu CFLAGS=-m32 LDFLAGS=-m32
Also see the output lines confirming this:
configure:3629: checking build system... | configure: error: C compiler cannot create executables |
1,349,361,022,000 |
Possible Duplicate:
What does a kernel source tree contain? Is this related to Linux kernel headers?
I know that if I want to compile my own Linux kernel I need the Linux kernel headers, but what exactly are they good for?
I found out that under /usr/src/ there seem to be dozens of C header files. But what is thei... |
The header files define an interface: they specify how the functions in the source file are defined.
They are used so that a compiler can check if the usage of a function is correct as the function signature (return value and parameters) is present in the header file.
For this task the actual implementation of the fun... | What exactly are Linux kernel headers? [duplicate] |
1,349,361,022,000 |
I'd like to try using a kernel other than the one provided by my distro -- either from somewhere else, or as customized by me. Is this difficult or dangerous?
Where do I start?
|
Building a custom kernel can be time consuming -- mostly in the configuration, since modern computers can do the build in a matter of minutes -- but it is not particularly dangerous if you keep your current, working kernel, and make sure to leave that as an option via your bootloader (see step #6 below). This way, if... | Configuring, compiling and installing a custom Linux kernel |
1,349,361,022,000 |
Sometimes in the sources of projects I see "*.in" files. For example, a bunch of "Makefile.in"s. What are they for and/or what does the ".in" part mean? I assume that this has something to do with autoconf or make or something like those, but I'm not sure.
I've tried searching for ".in file extension", "autoconf .in f... |
it's just a convention that signifies the given file is for input; in my experience, these files tend to be a sort of generic template from which a specific output file or script results.
| What are .in files? |
1,349,361,022,000 |
I understand that source based distributions like Gentoo or Slackware do not need *-dev versions of programs. They include the source code as well as header files for compiling everything locally.
But I never saw *-dev packages in Arch Linux, although it is package based. I ran across lots of *-dev packages in other d... |
The -dev packages usually contain header-files, examples, documentation and such, which are not needed to just running the program (or use a library as a dependency). They are left out to save space.
ArchLinux usually just ships these files with the package itself. This costs a bit more disk space for the installation... | Why are there no -dev packages in Arch Linux? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.