date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,380,717,179,000
I have a dataset that has a large amount of data in it: ID Number: A00001 Name: John Smith Address: 123 Any Street City: AnyTown State: Ohio Zip: 12345 ID Number: A00002 Name: Jane Doe Address: 123 Any Street City: AnyTown State: Nebraska Zip: 12346 ID Number:...
grep is a pattern matching tool, not a text reformatting tool. Use something like sed, awk, or perl instead. For example: $ awk '/^(ID Number|Name|Zip):/; /^[[:blank:]]*$/ { print "=========================" }' ID Number: A00001 Name: John Smith Zip: 12345 ========================= ID Number: A...
Is there a way to format output with grep or egrep with a separator between instances of the output?
1,380,717,179,000
I want to send output of a shell script, including user-entered text, to the terminal and a logfile. I thought some combination of tee and exec might do it, but I’ve had no luck so far. I know tee by itself can echo and capture what the user enters in the terminal: $ tee logfile Hello (I entered this at runtime) Hell...
The script implementation from util-linux at least is scriptable. You could do for instance: SHELL=/bin/sh script -qec ' # any sh code here echo Whatever cat # user input' file.log And file.log will capture all that is written to the terminal, including the echo of what you type. That also includes the transfor...
Is there a way to send all shell script output to both the terminal and a logfile, *plus* any text entered by the user?
1,380,717,179,000
I have a series 5 of commands working on several files located in several sudirectories. Suppose I want to redirect the output of every command as a new column in the same file, how can I do that. Kindly help me. For eg. in the series of commands below, I would like to redirect the output of command 1 into 1st column ...
If your shell supports process substitution, you could use the paste command as follows: paste \ <(sed -n -e '1,33p' myfile | awk '{ sum += $3 } END { print sum }') \ <(sed -n -e '34,40p' myfile | awk '{ sum += $3 } END { print sum }') \ <(sed -n -e '41,49p' myfile | awk '{ sum += $3 } END { print sum }') >> ../...
Redirect outputs to different columns of the same file
1,380,717,179,000
I can't seem to figure out how I can put a fdisk command from a bash script in a multiline variable. Here is my code hdds="$(sudo fdisk -l | grep "Disk /dev/sd" | awk '{print$2}' | sed 's/://g')" When I execute this bash script it puts everything on a single line like /dev/sda /dev/sdb When I execute this command ou...
are you calling the variable with echo, by any chance? If so, put it in double quotes, like this: echo "$hdds" or use printf: printf "%s" "$hdds"
Output fdisk bash command to multiline variable
1,380,717,179,000
I was checking what exactly each field is in the output of ls -l. The example in this post solves my question. But again I'm wondering what type of each field is. The strings are obvious. But how about the numbers? Like 10, 2048, are they integers or strings? Is there any way I can check the type of each field?
The text produced by commands in the terminal are text strings. Viewing raw binary data in the terminal, without converting it to some text representation, generally has a tendency to produce "garbled output" (for example, when running cat on a compressed file) and may in some cases even put the terminal in a unusabl...
How can I know the type of each element in the output of ls -l?
1,380,717,179,000
I am using a bash wrapper script around rsync so I run with --dry-run option and then grep on it's output to check for "deleting", so I can make sure I am not losing data by some mistake. (I have not been able to find deleted files on the log output via --log-file but that's a separate question). However, even if I am...
I've made the same mistake, and searched for an answer to this question too. I haven't found a way to change rsync's basic behavior in the way you've described. I work around it by creating a unique file in the source folder before I do my dry-run. If I see that file show up in rsync's log marked for deletion, I kn...
Absolute path names on rsync output
1,380,717,179,000
I executed the following code in my Bash console in an Ubuntu 16.04 environment: cat <<-'DWA' > /opt/dwa.sh DWA() { test='test' read domain find /var/www/html/ -exec cp /var/www/html/${domain} /var/www/html/${test} {} \; sed -i 's/${domain}/${test}'/g /var/www/html/test/wp-config.ph...
The last DWA is being removed because you are using this as your delimiter. The delimiters tell your shell everything between these matching strings is part of my here doc. The delimiters are not part of the doc and are therefore stripped when the here doc is read. The reason the DWA prior to that remained is becau...
cat heredocument copied everything besides function call
1,380,717,179,000
I have a bashscript, which executes a command and calculates a pair of values, which output can look like this. a,b (10.0000000000, 10.0000000000) -> volt (2088133.7088034691, -222653.3238934391) And in case of invalid parameters or errors the program can show different error-messages. Is there a safe way to parse the...
Depends on how reliable the output is and what happens when you get the "different error messages", ie., how that would have to be handled. A basic approach, with what you have above, you could use awk: awk -F"[)(, ]" '{printf "var1=%s\nvar2=%s\n", $11,$13}' var1=2088133.7088034691 var2=-222653.3238934391 A "saf...
Get two values from command output in a bash script
1,380,717,179,000
I am trying to capture mysql traffic and pass those traffic to strings command as follows: tcpdump -i any -s 0 -l -w - dst port 3306 | strings This is working as expected and printing all mysql queries like select * from mytables show databases But when i am trying to redirect the output to a file, its not printing...
I got the solution: Actually strings command is buffering. I disabled the buffering by using stdbuf -i0 -o0 -e0 command So after changing the whole command to the following, output started going to /tmp/final file. tcpdump -i any -s 0 -l -w - dst port 3306 | stdbuf -i0 -o0 -e0 strings > /tmp/final References stdb...
strange behaviour of strings command [duplicate]
1,380,717,179,000
When I run top I see a screen similar to this, PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 654 root 20 0 25.5g 147780 70084 S 3.7 0.9 72:08.69 Xorg 1687 me 20 0 9165008 1.4g 268488 S 1.3 8.9 163:06.01 qutebrowser 316 root -51 0 0 ...
I have been pretty successful with the ps -o output format field names. The output specifiers are mentioned a couple of times early in the Linux ps(1) man page: First a short ways into the EXAMPLES section: To see every process with a user-defined format: ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,com...
How can I obtain a full tabular list of the running process on my system (with their command name and PID at least) for text processing consumption?
1,380,717,179,000
The application in question is DaVinci Resolve. I start it from terminal. And when I close it, the message "Socket Disconnected" from the app is written to the terminal output. Then the bash prompt appears as normal. I start typing the new command, and suddenly another message appears in terminal "Socket Disconnected"...
Preliminary note I haven't tested davinci-resolve at all. This answer is designed to be generic. Analysis Your shell waits for davinci-resolve to exit before it puts itself back in the foreground and prints the prompt. Apparently some child (or further descendant) of the main davinci-resolve prints the unwanted messa...
How to prevent child process to interfere with bash prompt?
1,380,717,179,000
sda |-sda1 ntfs Recovery F49E60439E5FFD0C |-sda2 vfat 0E62-991B 61.6M 36% /boot/efi |-sda3 ...
It's just a layout-thing. It makes it easier for the user to see that sda9 and sdb2 are the last ones in their respective lists. Nothing to worry about.
Output of lsblk includes both pipes and back ticks
1,380,717,179,000
I was running a lengthy scientific simulation (which took almost a week to run) on my Linux workstation with the command which looked like this: time ./simulation So besides getting the output files from the simulation my aim was to also get the exact time it took to run this simulation. However, unfortunately, I ran ...
You can no longer access those lines in mate-terminal. Increasing the number of scrollback lines doesn't help either: The terminal doesn't remember all the lines and reveals only the configured amount; it remembers only the configured amount. That being said, if the given terminal tab is still open, there's still som...
How to see previous output in terminal window?
1,380,717,179,000
i have script that filter several text file using grep and awk in loop, my issue is when create output to each file after filtered, this my script: grep_multi.sh path=$(find /home/folder/file/source -iname "Tracert*" ) for i in "$path" do grep -E '^%%.*.%%$'\|'IPv4 type' $i | awk '/%%TRACERT:/ {sfx = $0; next...
By quoting the variable "$path" you are causing the loop to run once, with $i expanding to the whole list of paths. So your redirection ends up something like > filter.result./home/folder/file/source/Tracert_1.txt /home/folder/file/source/Tracert_2.txt ... which is "ambiguous". See this somewhat related question Why ...
grep multi text file input and create diferent output each file
1,380,717,179,000
In a directory, after running ls -d -- 0.*_*.txt | sort -t. -k1, I obtained output filenames such as 0.230_0.203059.txt How can I further writing each of them into two columns like 0.230 0.203059 into a txt file?
There is some aversion against parsing the output of ls (see https://mywiki.wooledge.org/ParsingLs among others), but that aside: ls -d -- 0.*_*.txt I don't know why you put the -- there; the -d just prevents you from descending into directories. In your set-up, you will probably need neither. The ls will generate fil...
Grep: separate output into two column and save them into txt file
1,380,717,179,000
I have a binary that I will be running multiple times in parallel, each instance executed with different input from the command line. I wanted htop to list only these processes so that I can compare the usage of memory based on the cli inputs. I tried [htop -p ] but this lists only one process even if I give muliple ...
From man htop: F4, \ Incremental process filtering: type in part of a process command line and only processes whose names match will be shown. To cancel filtering, enter the Filter option again and press Esc. So, once you start htop, type \test and press Enter to filter in only commands contai...
htop - See/Filter all the instances of a binary
1,380,717,179,000
I have an out from xmllint and egrep that I would like to print two fields next to each other. e.g. (xmlinput) xmllint --format | egrep reference\|sourcefile <reference>ItemX</reference> <sourcefile>://filepath/blah/blah/</sourcefile> <reference>ItemY</reference> <sourcefile>://filepath/blah/blah/</sourcefile> . . <re...
[your command] | paste -d '' - - will join consecutive lines.
Bash output two results next to each other
1,380,717,179,000
I have a script that connect to a Network device. It runs some commands and basically I want to output the SSH commands that are being executed. To make myself clearer, I connect to one device, execute the commands "execute fmscript showlog " and it shows some output. The thing is in the log file where the output is r...
How about CMD='execute fmscript showlog FG300D-1' echo $CMD > output.txt sshpass -p 12345678 ssh [email protected] "$CMD" >> output.txt
How to output SSH commands that are being sent to a server
1,380,717,179,000
I am working on a project to calculate my overtime at work with a shell script. I have two inputs and want to find if my number is over 800 = 8 hours; if it is bigger, then it has to print out the result to my text file. It has to print out my difference. if [ $var1 -gt 800 ]; then `expr $var1-800` echo Overtime: "...
Try this using modern bash (don't use backticks or expr) : if ((var1 > 800)); then overtime=$((var1 - 800)) # variable assignation with the arithmetic echo "Overtime: $overtime" fi Or simply : if ((var1 > 800)); then overtime="Overtime: $((var1 - 800))" # concatenation of string + arithmetic fi Check ba...
Echo calculation to text file [duplicate]
1,380,717,179,000
When I run curl https://example.com -o example.html 2>&1 | grep -P "\d.*\d" I get this output (in red): 100 1270 100 1270 0 0 318 0 0:00:04 0:00:04 0:00:00 318 What I want is just to show the last line of cURL's progress bar as it updates (I actually only want certain columns to be shown, but ...
You cannot directly | grep the output of curl progress because of pipe buffering. Some great insights on this issue is available in this previous question: Turn off buffering in pipe As for a solution, using stdbuf and tr: curl https://example.com -o example.html 2>&1 | stdbuf -oL tr -s '\r' '\n' | while read i; do ec...
Grep cURL output
1,380,717,179,000
Disclaimer: This is a more general question of the one I asked on biostars.org about parallel and writing to file. When I run a program (obisplit from obitools package) sequentially, it reads one file and creates a number of files based on some criterion (not important here) in the original file: input_file.fastq ...
It sound as if obisplit behaves differently if output is redirected. You can ask GNU Parallel to output to files: seq 10 | parallel --results output_{} echo this is input {} >/dev/null (or if your version is older: seq 10 | parallel echo this is input {} '>' output_{} ) It will create output_#,output_#.err,output_#....
why is this parallel process not writing output to files but printing to console instead?
1,380,717,179,000
I have a stream of info from a serial input (GPS Antennae) and wish to output that info into a text file on every input (every second in this case) but instead of appending it to the end of the file as > would do after the initial overwrite I would like it to overwrite it every second so only the latest info is displa...
You can print or printf straight to a file within awk, and close it after every write. That would make awk reopen and truncate it on the next print. awk -vfile=test.out '{print $0 > file; close(file)}' (Strictly speaking you get a race condition here, another process might try to read the file just between the trunc...
How to overwrite output file on every input update
1,380,717,179,000
I'd like to print command output along with its input. For example for such call as echo "Hello world" | wc -c I want the following output: 12,Hello world Is there any way to do this using standard Unix (or GNU) tools?
tee and paste solution: echo "Hello world" | tee >(wc -c) | tac | paste -s -d, - 12,Hello world
Combine command output along with the input [duplicate]
1,380,717,179,000
I've installed some utilities from the CLI and got quite a long verbose output describe what was installed directly, what needed some dependencies, what is no longer needed to be installed, etc. Is there a way to grep something from this last command ? A very certain word I need. Thanks,
I needed something that does that after I ran the installation command, and not for to-come installation commands. While I don't know a command to do it after the instillation command has been executed, what I did was to copy the output from Bash itself, into a text editor like Vi or Nano, and then search for all inst...
Grep something specific of the results of last execution?
1,380,717,179,000
I have the following scenario. I have a Perl script that takes an ID and looks up some arguments from a DB. lets say look_up_args.pl 234 prints the following abc 123 "something with spaces" I have another shell script script.sh that does the following some_command --param1 $1 --param2 $2 --par3 "$3" ... what I am tryi...
I wouldn't recommend this, but try: eval "./script.sh $(./look_up_args.pl 234)" This should work, but keep in mind that eval will evaluate whatever look_up_args.pl happens to output, meaning you leave yourself vulnerable to code injection. A better option would be what @thrig suggested in the comments: use a standard...
How to pass arguments to a script that were generated by another script
1,454,934,370,000
I have a PHP script I'm running from Cron. I want to save its output to file, but also want to save the shell output to a different file. Ideally, I'd like to have this in one line. As such, I tried the following: script "/folder/log/file.errors."`date +"%Y-%m-%d.%H-%M-%S"`".txt" && /usr/bin/php /folder/file.php > "/f...
Per terdon's request, I am posting this comment as an answer, so that the question can be marked as "answered" Instead of relying on script logging, especially if this will eventually be a cron job, consider sending output and error messages to one or more designated files(s) in your php code. When you run it i...
script Multiple Commands
1,454,934,370,000
When i run this command it still outputs the same message when nothing is in the waste bin directory, how could I get the command to output a different message when there are no files in the bin? #! /bin/bash #! listwaste - Lists the names of all the files in your waste bin and their size ...
Oneliner: trash() { ls -1 ~/bin/.waste; }; [[ $(trash | wc -l) -eq 0 ]] && echo no waste || echo -e "waste:\n$(trash)" Better formatted: trash() { ls -1 ~/bin/.waste; } [[ $(trash | wc -l) -eq 0 ]] && echo no waste || echo -e "waste:\n$(trash)" Nerd formatted: #!/bin/bash function trash() { ls -1 ~/bin/.waste } ...
How use an if statement to change the output message
1,454,934,370,000
I have a txt file with lines like below. Starting With: Parameters: {"raw_message"=>"MSH....... Ending With: </HL7Message>"} I'm wanting to grep and output to a file the words between raw and transformed which appears halfway through each line. The file appears like below Parameters: {"raw_message"=>"MSH....... "tr...
If you want just the text between your patterns on each line, do the following: sed 's/.*raw\(.*\)transformed.*/\1/' \(.*\) remembers the text that is output using \1. Other stuff onthe line is not output.
How to grep between words in a log?
1,454,934,370,000
Okay I'm pretty new to Linux and I have setup a Raspberry Pi 2 with Raspbian and it's running a bunch of things for tracking aircraft as well as a receiver (RTL-SDR). It's all working great and I'm using Dump1090 for decoding/demodulating the signal. Dump1090 has an --interactive mode that displays a row/column layout...
I haven't got dump1090 or a receiver to confirm any of this. But if you read further down in that github page you've linked you'll see that if you run: ./dump1090 --interactive --net it will start it's built-in web server. You can then connect to the Raspberry Pi's port 8080 with your web browser by entering it's IP ...
How to view a daemon's output in a session on Raspbian/Debian?
1,454,934,370,000
I have a access_log which size is neally 2GB. I want to analyze it from 2015:09:55 to 2015:09:57, but during this period, there have more than 500 items. So I want to output and download the access_log only from 2015:09:55 to 2015:09:57 in my computer and open it in my EmEditor. I am not good at SSH commond. I tried t...
You can specify a range with regexes as delimiters with sed. As an example, all entries, that contain anything between 2015:09:56 and 2015:09:6(something): ssh host "sed -n '/2015:09:5[6-9]/,/2015:09:6/ p' /var/log/httpd/access_log" to capture the output in a local file, use redirection, that is: ssh host "sed -n '/...
output log file from some time to some time via ssh
1,454,934,370,000
I'm having trouble with sending shutdown -h 0 to a lxc Debian container (i.e. executing this command in the lxc) with with the python pexpect module (in a python script). In this module the user can "expect" (= wait for process output) a certain substring, amongst others EOF, which leads me to the question in order to...
EOF indicates that no further input is to be expected on a resource which possibly provides an endless amount of data (e.g. a stream). This situation is often expressed by writing a single character on the stream (to be defined by the underlying system (likely a OS or runtime environment )). As processes use streams f...
Do all Linux processes write EOF to stdout when they are terminating/have finished terminating?
1,454,934,370,000
I am trying to use part of the hostname output in Linux and use it in a file using sed. For example, I am using this command as hostname |tail -c 4 which shows me output as last 4 numbers and then use this output and substitute it with another text inside a file. Assuming part of the hostname command shows with tail -...
You could store the output of the first command in a variable $ var=$(hostname |tail -c 4) Once stored, you can then use it as the replacement with sed $ sed -i.bak "s/oldtext/$var/g" filename.txt
Using hostname output in linux with sed
1,454,934,370,000
I have a mail.log line and using sed and pipes I can extract the subject, the sender, and the recipient of the mail, echo "Jul 15 09:04:38 mail postfix/cleanup[36034]: 4A4E5600A5DE0: info: header Subject: The tittle of the message from localhost[127.0.0.1]; from=<sender01@mydomain> to=<recipient01@mydomain> proto=ESM...
Ugly but put this at the beginning of the sed statement: -e 's/^\([[:alpha:]]+ [[:digit:]]+ [[:digit:]]+:[[:digit:]]+:[[:digit:]]+\).*Subject:\(.*\)/\1\2/' Or if you always know that ' mail postfix' will be in the text at that position you can just use: -e 's/^\(.*\) mail postfix.*Subject:\(.*\)/\1\2/' And other v...
print the date of a mail.log line
1,454,934,370,000
I try to install rar using yaourt, problem is I get +5k results and can't filter out the package containing rar. Neither |grep helps nor |head, the first hundreds of lines are lib'rar'ies. What could I do to get around this?
You use an AUR helper that actually works and is not fundamentally insecure: cower -s '^rar$' aur/rar 5.3.0-1 (668, 6.91) A command-line port of the rar compression utility
finding rar in yaourt
1,454,934,370,000
I had asked a question a while ago about how to pull specific info from a log file, and got some useful answers, but I don't quite have what I need yet. What I have so far: #!/bin/bash mkdir result cd $1 ls | while read -r file; do egrep "ERROR|FAIL|WARN" > ../errors-$file done cd .. mv errors-* result Here's wha...
I'll poke at your loop itself, and try to walk through what it's actually doing, and then look at how you might achieve what you want. How you initiate your loop is overly complex: ls | while read -r file;. You're piping the results of ls to your while read, not a big deal, still works, though I would recommend a for ...
Script that scans through logs, pulls specific data, and creates an output directory
1,454,934,370,000
I am writing a bash script for backup with log storage. I use my defined function as follows: logit () { echo " $1 $2 " >> /path/to/log } For logit 'Starting Backup' $(date +'%D %T') I get this output: Starting Backup 01/11/22 so the time is missing, apparently the stdout function has shortened it. With ec...
Double quote the command substitution: logit 'Starting Backup' "$(date +'%D %T')" Without quotes, the result of $(date ...) goes through word splitting and filename globbing. There's no shortening: assuming $IFS is still set to its default value (which does contain the space character), the date and time are passed a...
bash function does not show me date or cat arguments completely [duplicate]
1,454,934,370,000
I have a.txt,b.txt,c.txt. Each has different numbers as below: a.txt: 12 14 111 1 15 2 b.txt 12 18 22 23 1 2 c.txt 12 14 15 16 17 1200 The output should contain all the numbers from each file, but without any duplication. Is there a command to export such a thing into a text file? The actual text files include...
You could do like this if there are more number of files, grep '' *.csv | cut -d: -f2 | sort -u > output.csv
how to export all numbers that are unique in a few text files into another file?
1,454,934,370,000
Say I type git help to learn about the merge command. I don't want to read all the output just the lines that contain merge and their surrounding lines. I thought this would be a common question but couldn't find it. I think grep can be used somehow to do this.
Yes, grep can do something like this: its -C option will show the context of a match. Thus git help | grep -C2 merge will show lines containing “merge”, with two lines of context above and below. I find it more convenient to use less: git help | less then search using /. git help won’t tell you much though, you’ll ...
How can I search terminal output?
1,454,934,370,000
I have a command such that bar > /dev/null and I want to know the exit status of bar. I read some posts su about ${PIPESTATUS[0]} but this works when one pipes the output via | and I can't make it work with > instead. What am I missing?
> isn't a command. This means that bar will be the last command executed. You can check for failure with a standard if statement: if ! bar > /dev/null; then echo "bar command failed" fi You can also access its return code with $? if you are interested in something more than zero or non-zero: bar > /dev/null if [ ...
exit status and no output
1,454,934,370,000
I am trying to assign an resolved IP address to variable: ip=$(ping -q -c1 -W1 google.com | grep -Eo "([0-9]+\.?){4}" | head -n 1) | echo $ip or ip=`resolveip google.com | head -n 1` | echo $ip Both echo returns empty output. Without assigning it to variables commands works good. What i am doing wrong?
What you want to achieve seems to be outputting the content of the shell variable $ip after assigning the output of the ping command to it - that means, you want to first assign command output to a variable, and then print the resulting variable content on the console. However, you are using the pipe (|) operator to l...
Assigned variable has empty output from nslookup and ping commands
1,454,934,370,000
How can I merge the output of two commands in one, using one command? command1 output: ID NAME1 COLUMN2 xxx-1 aaa bbb xxx-2 ccc ddd xxx-3 eee fff xxx-4 nnn mmm command2 output: COLUMN3 COLUMN4 ID kkk www xxx-3 kkk ppp xxx-1 kkk qqq ...
awk 'NR==FNR{a[$1]=$2; next} {$3=a[$3]} 1' <(command1) <(command2) might be what you're looking for. I tweaked the above and re-ran given the output the 2 command scripts you added produces: $ awk ' NR==FNR { map[$1]=$2; next } { key=$NF; sub(/[^[:space:]]+[[:space:]]*$/,""); print $0 map[key] } ' <(./command...
Substitute or merge output of two commands in one, using one line command
1,454,934,370,000
Having to deal with an environment where ack and so on is not available nor installable, this command try to limit only relevant files to find string through the C++ project : grep pattern --color -- /project/path/**/*.*([chCH]|cc|cxx|[ch]pp|py) This does the job. Now to bring a bit more commodity to that, the goal ...
The extglob shell option enables the *([chCH]|cc|cxx|[ch]pp|py) part of your expression, but the **/ part requires the globstar option globstar If set, the pattern ** used in a pathname expansion con‐ text will match all files and zero or more directories ...
Shellscript `grep` execution not working as in the interactive shell
1,454,934,370,000
I used ls ~ on RHEL 7 but I got <F6>q as output! What does it mean? [user@server2 ~]$ ls /home/user/ <F6>q [user@server2 ~]$ ll total 4 -rw-r--r--. 1 root root 340 Sep 18 17:16 <F6>q [user@server2 ~]$ cat <F6>q -bash: F6: No such file or directory [user@server2 ~]$ touch test [user@server2 ~]$ ls <F6>q test [user@se...
It means that your file is named <F6>q. These are not undisplayable characters, as comment-answers and other actual answers suggest. You can see them displayed, right in front of you. ☺ In any case, <F6> is not any of the forms that ls emits for undisplayable characters. [user@server2 ~]$ cat <F6>q -bash: F6: No s...
What does <F6>q mean in ls command output?
1,454,934,370,000
To edit the root crontab in Debian I do for example sudo crontab -e. To exit from the preferred text editor (Nano), I do CTLR+X. So far so good, but what if I want that each time I exit crontab, a text will be echoed into the console (into "stdout"). The purpose is to echo a reminder message like: If you haven't alre...
You can assign the $EDITOR variable a script which first calls an editor and then produces the output: #! /bin/bash vim "$1" echo "foo bar baz" and use this call EDITOR=/path/to/script.sh crontab -e
Echo something to console each time you quit crontab
1,454,934,370,000
When we are trying to redirect an output from an production server to local system, there are some unwanted characters eg. ^[[032m. actually these are the color codes which is appearing while its redirected. When the same script is executed on the server without redirection some part of the output appears in colored f...
If you have GNU sed, you can use that to remove the color escapes from the stream: somecmd |sed -Ee 's/\x1b\[[0-9;]+m//g' > outputfile The sed command substitutes (s///) the escape character (\x1b), followed by an open bracket (\[), and any number of digits or semicolons ([0-9;]+) and a following m, with nothing.
unwanted output characters eg. `^[[032m` from a script
1,454,934,370,000
Literally, I want to print to any displayed line on the terminal. I remember we've learned this in university, but was ages ago. Is there a command for this? Like this: ___________ ___________ |blah | |blah | |bla | |blah | |randomtext | |blah | ...
You can move the cursor to any X,Y co-ordinate with the tput cup command eg tput cup 10 3 will take you to line 10, column 3 (co-ordinates start at 0,0 as the top-left) so a simple script such as clear echo line 1 echo line 2 echo line 3 tput cup 1 5 echo another line tput cup 10 0 will result in output similar to ...
How to modify a given line of the terminal?
1,454,934,370,000
I feel like the space between the numbers and the paths is too much and I believe that less space would make lines easier to follow. Is there an easy way reduce that space?
That's a TAB, you see a 7 column gap because your terminal has tab stops every 8 columns. You could change the tabstop spacing on the terminal with for instance: tabs 4 To set the tab stops every 4 columns instead of 8, or pipe the output to: expand -t4 To convert TABs to spaces with tabstops every 4 column. Or expa...
Reduce space between numbers and paths in "dirs -v" output
1,526,039,478,000
I'm confused on how bash interprets blanks while executing a script. In the end, I want a script that is fed by a csv file containing software used by an organisation and it should return the CVEs for these programs, by calling a python script to fetch this information. My file would look this, but with over 500 lines...
Your problem comes from IFS=";" I think: this modification will have an impact on the for loop. Try: IFS_OLD=$IFS IFS=";" while read title firm desc version manager do query='"'$(echo $firm $title $version | tr -d '"')'"' var3=$(python3 $HOME/cve-search/bin/search_fulltext.py -q "$query" | tr '\n' ' ') ech...
Shell script - blanks are not always recognized as such?
1,526,039,478,000
Below is the output of uptime from Solaris where I am extracting the third last column: uptime 8:30pm up 23 day(s), 17:46, 5 users, load average: **2.79**, 1.79, 1.53 I always need to get the third last column highlighted in bold above i.e. 2.79 echo '8:30pm up 23 day(s), 17:46, 5 users, load average: 2.79, 1.7...
Read man cut and do something like: uptime | cut -d, -f4 | cut -d: -f2
Unable to get the nth column data due to changing output of uptime command
1,526,039,478,000
I'm able to get the output of a failing lp command from a remotehost to my local script like below: until ssh -q root@remotehost 'lp -d Brother_HL_L2350DW_series /root/moht/Printed/`basename "$FILE"`' 2>&1 | tee /home/printererror.log do echo "Issue is: `cat /home/printererror.log`" sleep 230 done The issue is the ...
The until is considering the exit status of tee. Looking at your code it's not at all obvious why you should need tee, though, so I'd suggest you just remove it until ssh -q root@remotehost 'lp …' >/home/printererror.log 2>&1 do : … done
Get the output of a remote ssh to local
1,526,039,478,000
I want to print the following variables to the standard output file slurm-XXXXX.out produced by Slurm. Right now, I am generating a separate .info file for every job. echo "SLURM Job ID : ${SLURM_JOB_ID}" >> $SLURM_SUBMIT_DIR/$jobName.$JOBID.info echo "SLURM Job name : ${SLURM_JOB_NAME}" >> $SLURM_SUBMIT_D...
Just echoing these variables without the redirection to your info file will output to .out file, like echo "SLURM Job ID : ${SLURM_JOB_ID}"
How do I print slurm variables to standard slurm output?
1,526,039,478,000
I'm currently doing some Bash scripting and have built a tool that returns log information. However, the script sometimes returns a lot of lines (depending on what is going on on the network) and Ctrl+S helps to read the printed lines by "freezing" the output. I've read that the Bash pauses flow-control (XOFF) when pr...
That behaviour has nothing to do with bash (or any shell for that matters). It's the terminal device driver that pauses output (stops sending data to the terminal) when it receives the ^S character (or whatever is set by stty stop) from the terminal. Applications started by your shell in that terminal won't see that ^...
Print a message before the Bash pauses its output
1,526,039,478,000
I have a function that takes a filename. It then runs a command and filters the output (exclusive) between two patterns, then it outputs comma separated values with the filename output of the command. Here is the function and the expected output: get_cons_obs() { local line="${1}" "command" -i "${line}" 2>&1 ...
It sounds like you want to pass the shell variable line into awk so that you can print it when flag is non-zero Ex. awk -v line="$line" '. . . flag {printf "%s,%s\n", line, $0}' See also Use a shell variable in awk
Append text to flagged output of awk
1,526,039,478,000
I ran across a problem formatting the output during runtime while preserving the format of the code in some scripts. The below works for me, just wanna check that it's reasonable? It seems to dirty up the code a bit, I'd be interested in a better solution - I don't want to create an over complicated bash function that...
If you use Tab characters for indentation (all but extinct nowadays) you can use this trick in here documents: if … then cat <<- EOF first second EOF fi If you replace four spaces with tabs in that command it'll print the same as printf '%s\n' first second. That said, printf '%s\n' … is probab...
Clean formatting of output within bash scripts
1,526,039,478,000
While I type a command, this command will authenticate with a remote server and do a bunch of things. If pass, it will give me a bash shell with its environment. My goal is to save these log which prints out into my terminal for future inspection. Let's say my command called target. While I type target, it throws the ...
You may want to try script: script -c target output.log This would start the command target and save a transcript of the whole session, until target terminates, into the file output.log. If the command (your target) is several words long, quote the full command. See the manual for script (man script).
Echo shell log while entering and then exit
1,526,039,478,000
I have a LAMP environment with /var/www/html/x which is a MediaWiki website. I have a few more MediaWiki websites but I'd like to print the version of the x one to terminal. I need to do so I could know what the last version was before I manually update MediaWiki. Inside that dir, there's a file named RELEASE-NOTES-1....
If the wiki is up, the most robust method is to just ask (via the generator property of the siteinfo API, for example) - changes to that are subject to a deprecation policy, while any internal structure you rely on could change without warning. If that's not an option, you can try parsing out the value of $wgVersion f...
How to print the version of a specific MediaWiki installation to terminal
1,526,039,478,000
In a CentOS bash, (or, if there is a general way in other bashes, like Ubuntu, better), how can I differentiate commands typed by me with the output of the commands? I ask this because when I use a command who outputs a lot in the screen, it is hard to find where it starts. I want to, for example, decorate my commands...
For starters, bash is bash, no matter where it's running. The only important thing to note is which version. bash 4 has some new features not available in bash 3 for instance. That said, you can colorize up your prompt fairly easily by setting PS1 ("Prompt String 1") to set one command apart from another. For insta...
Differentiate/decorate the command line input and output (with color or indentation)
1,526,039,478,000
So I am using getent to reverse lookup a domain name to an IP. I need this IP in the munin-node config. I have the following code, but it just prints the IP and doesn't append to the config file. HOSTIP= getent hosts google.nl | awk '{print $1}' echo "allow ^$HOSTIP" >> /etc/munin/munin-node.conf
Your command is wrong HOSTIP= getent The space between "=" and "getent" dont work in bash. And you need to put command inside a sub-shell "$()" HOSTIP=$(getent hosts google.nl | awk '{print $1}') echo $HOSTIP 2800:3f0:4001:801::2003
Appending a string to a file with variable content
1,526,039,478,000
Due to my laziness, I have written an extremely "messy" series of scripts in order to auto-initiate my openvpn. The configuration file I am using comes vpnbook.com/freevpn. To get the password I use: lynx --dump --nolist vpnbook.com/freevpn | grep -i password | sort -u | cut -b 18,19,20,21,22,23,24 The password is r...
In your expect/tcl script, you can use: send "$env(PASSWORD)\r" And call your expect script with with: PASSWORD=$(elinks -dump...) /path/to/your/expect/script Note that you can use cut -b18-24 for short.
How can I update a unique string in a shell-script with the output of a seperate function?
1,526,039,478,000
I have a command in my csh script that can give at least 2 lines of output but may be more. I am turning these lines into separate variables that I then want to pass to another command. How do I set my second command to loop through and run for each variable outputted from command 1? Below is my what I have that turns...
Note, I'm using bash, not csh, because I don't hate myself. But you can do all this in csh, you'd just have to translate. If you want to work in bash instead, simply run "bash --login" first and then you're working in bash. To do the sort of task you describe in a shell script, we use pipes and not loops like you woul...
How to loop through variables
1,526,039,478,000
Official docker is installed on this Mac El Capitan. While running a bash file, one of the commands is to start the docker daemon if it is not running: [[ $(docker-machine status) == "Stopped" ]] && docker-machine start eval $(docker-machine env) I am guessing it was not running because I got the below output...
Docker on OS X (or macOS as it's now called) runs inside a Linux virtual machine, usually using VirtualBox as the hypervisor. So when you start docker using docker-machine start, it will take a little while for the virtual machine to and all of the services on it to start and become available. So to work around this...
shell script to ensure Docker Daemon is running - Official docker on OSx
1,526,039,478,000
I want the user to be able to name a file to be created, and then have the output of the script redirected to that file. The script will create a long listing of a directory and count the number of files in that directory. This is what I have so far: echo -n "Please enter the name of a file to be created: " read FIL...
Quite simple: #/bin/bash echo -n "Please enter the name of a file to be created: " read FILENAME ls -l Assign_7 > $FILENAME echo >> $FILENAME ls -l Assign_7 | wc -l >> $FILENAME This is called Parameter Expansion, see man bash for complete explanation. Also, there is a bit shorter form that simplifies the script a...
Redirecting the output of a script into a file? [closed]
1,526,039,478,000
So my goal is to answer my other question I am working on. Which is Connect to Open Wifi. Currently I am getting close, as I know there is only one Wifi connection, I would like to export the results of sudo iwlist wlan0 scan | grep ESSID to a text file. The output currently is: ESSID: "MyNetworkSSID" # Which would...
Don't bother with grep. Pipe it directly to awk as follows: $ sudo iwlist wlan0 scan | awk -F ':' '/ESSID:/ {print $2;}' "BTWifi-with-FON" "BTHub5-FTQN" "BTWifi-X" "4GEEOnetouchY800z_2DEB" This carries out a regexp search for ESSID: and the splits that line on a colon (-F ':') after which it prints the second elemen...
sudo iwlist wlan0 scan | grep ESSID > essid.txt (How do I export without the word ESSID in txt file)
1,526,039,478,000
Is there a way to append my_computer.sh with the command on line 330 by only referencing the line number? or with the fewest keystrokes possible? 326 pip install -U pip 327 man pip 328 cat >> ~/my_computer.sh 329 pip -V 330 sudo pip install virtualenv 331 ls 332 vi .gitignore 333 ll 334 vi...
It depends on your shell and the supported features. With bash, e.g., you can type: !330 my_computer.sh
append file with history line number values
1,526,039,478,000
What I want to do is to ask the user to enter one line and send to standard ouput. I tried get the input to carry out a conditional question, but there's no way to expand a input (in this case is input 0, but can be output 1 or error 2). In this scenario I want to ask and read the user input from standard input and se...
You really should study a beginner's guide rather then trying to guess at the syntax. Shell script is strange. Really. Here's a version that does what you've described: #!/bin/sh # read a line of text into the variable "$line" IFS= read -r line # check if the result contains any text if [ -n "$line" ] then # it ...
Expand input, output or error
1,282,094,234,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,282,094,234,000
I'd like to compress and package everything, including files and folders in current directory, into a single ZIP file on Ubuntu. What would be the most convenient command for this (and name of the tool needed to be installed if any)? Edit: What if I need to exclude one folder or several files?
Install zip and use zip -r foo.zip . You can use the flags -0 (none) to -9 (best) to change compressionrate Excluding files can be done via the -x flag. From the man-page: -x files --exclude files Explicitly exclude the specified files, as in: zip -r foo foo -x \*.o which will ...
Zip everything in current directory
1,282,094,234,000
In the Debian family of OSes, dpkg --search /bin/ls gives: coreutils: /bin/ls That is, the file /bin/ls belongs to the Debian package named coreutils. (see this post if you are interested in a package containing a file that isn't installed) What is the Fedora equivalent?
You can use rpm -qf /bin/ls to figure out what package your installed version belongs to: [09:46:58] ~ $ rpm -qf /bin/ls coreutils-8.5-7.fc14.i686 [09:47:01] ~ $ Update: Per your comment, the following should work if you want only the name of the package (I just got a chance to test): [01:52:49] ~ $ rpm -qf /bin/ls ...
Which Fedora package does a specific file belong to?
1,282,094,234,000
I am currently looking for a website or a tool that would allow me to compare the package state of a particular software in different Linux distributions. For instance, which version of gimp is provided by Mint, Ubuntu, Debian Sid and Fedora 18? An immediate interest would be to be able to avoid reinventing the wheel ...
whohas package (link) may help you. Example % whohas pidgin|grep "pidgin " MacPorts pidgin 2.10.6 https://trac.macports.org/browser/trunk/dports/net/pidgin/Portfile Slackware pidgin 2.7.11-i486-3s...
Is there a tool/website to compare package status in different Linux distributions?
1,282,094,234,000
How can I write a simple derivation to package a program for nix and how can I create a PR to include it in nixpkgs? (I am writing this as I can't find simple explanations)
NB: this answer is not yet fully complete, but it's already a good starting point. I plan to add more language-specific stuff later (or maybe to create one question per language too keep this answer… """reasonably""" short). Here are a few references: Quickstart in the manual : we will go in more details here The Nix...
How to package my software in nix or write my own package derivation for nixpkgs
1,282,094,234,000
It's all very confusing. There are different examples out there, for e.g.: <package-name>_<epoch>:<upstream-version>-<debian.version>-<architecture>.deb source: debian package file names Is section 5.6.12 Version or the Debian Policy Manual also related to the actual package filename too? Or only to the fields in th...
My understanding is that you want to distribute/deploy a package to multiple Debian based distributions. In the Debian/Ubuntu world, you should not provide individual .deb file to download and install. Instead you should provide an APT repository. (in the Fedora/Red Hat/CentOS world I would make a similar advice to pr...
Debian package naming convention?
1,282,094,234,000
Examining a buildlog from a failed build, what does the following error mean, fatal error: ac_nonexistent.h: No such file or directory #include <ac_nonexistent.h> Here is some context. configure:6614: $? = 0 configure:6627: result: none needed configure:6648: checking how to run the C preprocessor configure:6679: gcc...
That’s a sanity check, to ensure that the configuration script is correctly able to determine whether a header file is present or not: it asks the compiler to use a non-existant header, and checks that the compiler (correctly) fails. Note that your build goes on after that “error”... To figure out the cause of a build...
What is ac_nonexistent.h?
1,282,094,234,000
When showcasing applications, Windows and Mac mostly talk about features. Linux applications, on the other hand, have more details about what language was used to write it (and accompanying libraries) rather than features. Why is that? I could understand knowing the difference between GTK+ versus QT making a differen...
I think the traditional Linux user (a geeky tinkerer who actually installed the system by self) does care about such information (what technology is behind this tool?). I am also one of those geeky guys who would, for example, refrain from installing and using a package just because it uses some technology I don't lik...
Why do Linux applications often put the language it was written with in the summary?
1,282,094,234,000
I want to get detail about binary package and run them on linux. I am running Debian base (Ubuntu/Linux mint) Linux os. How to build binary package from source? And can I directly download binary package for applications (like firefox, etc.) and games (like boswars, etc.) ? I run some direct package which is in "xyz....
In a strict sense a binary file is one which is not character encoded as human readable text. More colloquially, a "binary" refers to a file that is compiled, executable code, although the file itself may not be executable (referring not so much to permissions as to the capacity to be run alone; some binary code file...
What is Binary package? How to build them?
1,282,094,234,000
To be more specific, I would like to do the equivalent of adding the --purge flag to the following command sudo apt-get autoremove --purge [package name] to packages that are no longer on the system. Preferably, I would like to know how to do it to specific packages and to every uninstalled package in the system.
The following should do what you want: aptitude purge \~c This purges all packages with the c (package removed, configuration files still present) state flag. Flag documentation is here.
In Debian based systems, how do we purge configuration files of packages that have already been uninstalled?
1,282,094,234,000
I love (the way) how Linux & Co. lets users install many packages from different repositories. AFAIK, they come also with source-packages, so you can compile them by yourself. But why even bother to "keep/offer" pre-compiled packages, when you could just compile them yourself? What are the intentions of keeping/offeri...
It’s a trade-off: distributions which provide pre-built packages spend the time building them once (in all the configurations they support), and their users can then install them without spending the time to build them. The users accept the distributions’ binaries as-is. If you consider the number of package installat...
Why are there pre-compiled packages in repositories?
1,282,094,234,000
CONTEXT With a local package repository, I'm able to provide my APT instances with a set of software packages and configurations from a server which I control, allowing any client to install this software using just the normal apt install command (providing the repository is added to their /etc/apt/sources.list{,.d/})...
There are a number of ways of going about this; I use apt-ftparchive. Create an aptftp.conf file in the root of your repository: APT::FTPArchive::Release { Origin "Your origin"; Label "Your label"; Suite "unstable"; Codename "sid"; Architectures "amd64 i386 source"; Components "main"; Description "Your ...
How to generate the `Release` file on a local package repository?
1,282,094,234,000
The established structure of the .deb file name is package_version_architecture.deb. According to this paragraph: Some packages don't follow the name structure package_version_architecture.deb. Packages renamed by dpkg-name will follow this structure. Generally this will have no impact on how packages are insta...
Over the years, I’ve accumulated a large number of .deb packages with non-standard names, and I don’t remember running into any problems. “Famous” packages with non-standard names that people might come across nowadays include google-chrome-stable_current_amd64.deb and steam.deb. (In both cases, the fixed, versionless...
Is it safe to rename .deb file named by the standards?
1,282,094,234,000
I want to build a debian package with git build package.(gbp) I passed all steps, and at least, when I entered gbp buildpackage, This error appeared. what does it mean? and what should I do? gbp:error: upstream/1.5.13 is not a valid treeish
The current tag/branch you are in, is not a Debian source tree, it doesn't contain the debian/ directory in its root. This is evident because you are using a "upstream/" branch, a name utilized to upload the pristine source tree to git repositories. Try using the branch stable, testing or unstable, or any branch that ...
what does " gbp:error: upstream/1.5.13 is not a valid treeish" mean?
1,282,094,234,000
I am trying to edit an Apache module on Debian (strictly, I'm doing this on Raspbian Jessie-Lite), and am broadly following the Debian build instructions: $ mkdir -p ~/src/debian; cd ~/src/debian $ apt-get source apache2-bin $ cd apache2-2.4.10 $ debuild -b -uc -us And the build process takes roughly one and a half h...
Add the -nc option to your debuild command line. This may expose problems in the build system or the packaging though, so be prepared. But for small fixes it usually works fine. However, as the apache2 source package uses debhelper (like many other packages), this alone is not enough, because debhelper also keeps its ...
How to prevent debuild from performing a clean?
1,282,094,234,000
I have a .deb debian package which essentially contains the binaries of the software as a /usr/share/bin folder in a compressed data file, and another metadata compressed file containing the checksums of the other files. My goal is to create a PKGBUILD to install such .deb package correctly on archlinux. What's the pr...
Yes, it will work in the same way as other PKGBUILDs with binary sources - extract it and copy files. The only thing which should be mentioned is that deb-archive consists of 3 other files - debian-binary, control.tar.gz, data.tar.gz. makepkg will extract only first-level archive and then you should manually extract d...
Create PKGBUILD from .deb
1,282,094,234,000
The source code in not open or free, so compilation at installation is not an option. So far I have seen developers that: provide a tar.gz file and it is up to user to uncompress in suitable location. provide a .tar.gz with an install.sh script to run a basic installer, possibly even prompting user for install optio...
I see two ways to look at it. One is to target the most popular Linuxes, providing native packages for each, delivering packages in popularity order. A few years ago, that meant providing RPMs for Red Hat type Linuxes first, then as time permitted rebuilding the source RPM for each less-popular RPM-based Linux. This...
What installer types should commercial software use to support Linux?
1,282,094,234,000
I am running debian stretch and following this guide for building package from source for debian. Sometimes building process takes hours , when I run dpkg-buildpackage -rfakeroot again , it starts building from scratch. dpkg-buildpackage --help does not show any option to resume. How can I resume package building ...
To continue a build that was interrupted for some reason, you can call the appropriate targets of debian/rules directly: debian/rules build will compile the sources, then fakeroot debian/rules binary will run the installation and prepare the packages.
How to resume package building in debian?
1,282,094,234,000
I have created a package of zsh 5.0.7 from sources and now I can install it successfully but when I try to remove it I get this: $ sudo dpkg -i zsh_5.0.7_amd64.deb Selecting previously unselected package zsh. (Reading database ... 177638 files and directories currently installed.) Preparing to unpack zsh_5.0.7_amd64....
In general, this warning is completely harmless and normal. When dpkg is removing (or trying to remove) a package, it removes all files and directories which were created as part of that package installation. Now, suppose there are some files in a directory that is a candidate for removal in such a scenario, and dpkg ...
After creating a .deb: dpkg:warning while removing, directory /usr/local/bin not empty so not removed
1,282,094,234,000
I wand to build multiple .deb packages from same source for different versions and distros. Even if the source code is exactly same, some files in debian folder can not be shared because different dependency and distro name. So, I want to make multiple 'debian' directories for each version/distro and specify where to ...
Using different branches is one approach, and I can suggest edits for @mestia’s answer if it seems appropriate (but read on...). Another approach is to keep different files side-by-side; see Solaar for an example of this. But both of these approaches have a significant shortcoming: they’re unsuitable for packages in D...
Build the same source package for different Debian based distros
1,282,094,234,000
I know that apt-get source <package_name> gives you the source package. It contains a debian folder with a file called rules. If I understand it correctly, this file describes how the source package can be transformed into a .deb package, including which compiler flags should be used. Two questions: How do I get the ...
The compiler flags used are a function of the debian/rules file, the package's build files (since the upstream author may specify flags there too), the build system used (dh, cdbs etc.), the default compiler settings. To see the flags used you effectively need to at least compile the package: debian/rules build Try...
How to get the compiler flags that are used to build the binaries in a (.deb) package?
1,282,094,234,000
There's a .deb software that doesn't have a .desktop file, I created that file. I want to create another package for that software, when the user installs it, I want the .desktop file to be generated automatically and placed in /usr/share/applications/ How to do so?
Sounds like all you want to do is extract your .deb archive, add your .desktop file and the rebuild the package. This is a fairly simple process. To extract: dpkg-deb -R package.deb extract_dir Note -R is a raw extract to get the control files as well. Next create /usr/share/applications/ if it doesn't already exist:...
How to automatically generate .desktop file?
1,282,094,234,000
I need to build a project which depends on the particular version of third-party library: ➜ cat debian/control Source: libhole-cpp Priority: optional Maintainer: Vitaly Isaev <[email protected]> Build-Depends: debhelper (>= 9), cmake, flatbuffers (= 1.2.0-1), libboost-dev, libboost-system-dev, catch...
tldr; Delegate to the aspcud solver via apt-cudf-get: mk-build-deps \ --install \ --remove \ --tool \ 'apt-cudf-get --solver aspcud -o APT::Get::Assume-Yes=1 -o Debug::pkgProblemResolver=0 -o APT::Install-Recommends=0' \ debian/control Explanation This solution differs from that of Johannes Schaue...
Debian packaging: mk-build-deps cannot install particular version of Build-Depends packages
1,282,094,234,000
I have tried creating these scripts, the install goes well, however, once the application version is bumped and say I try to upgrade to apx v2.0 nothing goes well. This is my postinst script #!/bin/sh set -e chmod 755 /usr/bin/apx chmod 755 /usr/lib/apx/apx.py chmod -R 755 /usr/lib/apx/data/binaries exit 0 this is...
You should delete them. Your postinst only sets file permissions; these are supposed to be set in the packaged contents, not in a post-installation script. Your postrm deletes log files, and files inside the uninstalling user’s home directory (assuming it’s uninstalled using sudo); both of these are definite no-nos, h...
How can I create a proper debian postinst and postrm script?
1,282,094,234,000
Flatpak and snapd packages are available on other distributions because their respective package managers being built for installation on multiple distros [1][2]. Is this also true for the Guix package manager? I remember hearing that Guix packages were (or will be) installable on Debian, but I can't find a reference....
I'm an occasional Guix contributor. Yes, you can run Guix packages on top of other distributions (GuixSD is a standalone distribution of Guix, whereas Guix itself is a package manager, so it can be used under any other distribution). The Binary installation section shows you how to easily set up Guix on top of anoth...
Can Guix packages be delivered to other distros?
1,282,094,234,000
I know I can list the files in a package using the following command, which first download the package (.deb) into /var/cache/apt/archives and then list its contents: apt-get --download-only install <pkg> dpkg --contents <pkg> (.deb) Does apt-get support any way of listing the package contents without first download...
I don't think that apt-get can do it, no, but apt-file can: sudo apt install apt-file sudo apt update And then: sudo apt-file list <pkg> For example: $ sudo apt-file list xterm xterm: /etc/X11/app-defaults/KOI8RXTerm xterm: /etc/X11/app-defaults/KOI8RXTerm-color xterm: /etc/X11/app-defaults/UXTerm xterm: /etc/X11/ap...
Is there any way to display the package contents using `apt-get` without first downloading the package? [duplicate]
1,282,094,234,000
I've seen an interesting pattern in RPM packaging. The main library package will include the shared library itself: /usr/lib64/libavcodec.so.54 The -devel package will provide headers and a symlink: /usr/include/libavcodec/libavcodec.h /usr/lib64/libavcodec.so -> /usr/lib64/libavcodec.so.54 Why is the libavcodec.so ...
Software from the distribution is mechanically linked consistently, and expects to find libavcodec.so.54, so the unversioned name isn't required for any of the pre-built packages. If you're building software yourself, however, it's common to use -lavcodec or similar, which will find libavcodec.so unversioned. Similarl...
Why are .so packages provided by the devel packages?
1,282,094,234,000
I'm a little confused about RPM's in Red Hat and/or Fedora (and/or other distros?). I can certainly accept that 64-bit RPM's are needed for 64-bit OS'es and 32-bit for 32-bit OS'es but... If I have an RPM for ... OpenOffice.org, is that RPM valid for any of my RPM-accepting OS'es or do I need to seek out an RPM speci...
As usual: The answer depends. RPMs (or basically any given binary package container) contain runnable code. Most of the time that code depends on certain libraries or programs, the package specifies that it does for example depend on library libA in a version >= 1.0. Now take two different distributions with both usin...
Are RPMs valid across platforms?
1,282,094,234,000
I know that different distributions patch the packages that are available in the respective repositories but I've never understood why is there a need to do so. I would appreciate it if somebody could explain or point me to the relevant documentation online. Thanks.
It took a few tries, but I think I comprehend what you're asking now. There are several possible reasons for a distribution to patch given software before packaging. I'll try and give a non-exclusive list; I'm sure there are other possible reasons. For purposes of this discussion, "upstream" refers to the original sou...
Why do different Linux distributions need to patch packages?
1,282,094,234,000
How to build a debian package from a bash script and a systemd service? The systemd service will control the script by starting/stoping ready to use after the .deb will be installed successfully. From a web searching there are some easy exemples to convert only a single file (python, shell , ruby ... script) to .deb.
Here’s a minimal source package which will install a shell script and an associated service. The tree is as follows: minpackage ├── debian │   ├── changelog │   ├── control │   ├── install │   ├── minpackage.service │   ├── rules │   └── source │   └── format └── script script is your script, with permissions 755...
How to create a debian package from a bash script and a systemd service?
1,282,094,234,000
Is it feasible to build an RPM package and then utilize alien to create the DEB package rather than investing time in building a DEB package? Or do certain pieces not translate well?
Alien is good in some cases, i.e. you want to install a package fast and there is only a DEB or RPM for that package. From my experience Alien is not reliable for deploying a package in a distro. i.e. you created a RPM package from your project, and you now want to create a DEB package as well, and not wanting to spe...
How well does alien work for converting packages?
1,282,094,234,000
Is there a standard for source packages to be able to build rpms, debs (and perhaps others) without too much customization? I'm talking mostly about Python, PyQt programs.
FPM can build debs/rpms from python packages on PyPI or from a local setup.py file. You can build a deb with fpm -s python -t deb $package-name-on-pypi or fpm -s python -t deb setup.py Building packages in other formats only requires you to change the -t (target type) parameter. To produce debs I can also recomme...
Creating deb and rpm from the same source
1,282,094,234,000
I tried to make && make install package, but I get an error: libX11.so.6 not found Where can I get this library?
You need to install the libX11 package: $ rpm -qf /usr/lib/libX11.so.6 libX11-1.3.1-3.fc13.i686 Just go $ yum -y install libX11 One more thing though: if you don't know how to find and install a library package, care to share why you are trying to compile a piece of software that is officially packaged for Fedora...
libX11.so.6 Not found
1,282,094,234,000
I'd like to know how bug fixing exactly works in Linux distributions. I mean, after all a distro is made of opensource software made by external developers, and then packaged by the distro's maintainers. So why every distro has it own bug tracker? Shouldn't these bugs be submitted to the original authors of such soft...
(I'll refer to original authors or original software as upstream authors and upstream software because that's what I'm used to calling them.) From the end-user's perspective, it's nice to have a single place to report bugs, rather than having to sign up for accounts in various upstream bugtrackers for all the software...
How bug fixing exactly works in a distro ? upstream vs downstream
1,282,094,234,000
I followed a tutorial to make a package application, but it only deals with the source; there's absolutely no other file types mentioned. How do I include data files so that I can access them from my application in a package? For example, in the makefile, there's a $(DESTDIR) option, but I would never move the data fi...
If you are including binary data (pictures) you will want to create a version 3.0 package. You put the additional files inside the debian/ directory and either move them from the debian/rules script using install -D -m 644 debian/filename $(DESTDIR)/path/to/install/to or using the debian/install file to list the file ...
How to include data files (pictures, text files, ...) in a debian package