date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,591,436,750,000
I'd like to list let's say all of the following interfaces: p4p1 p4p2 p4p3 p4p4 Instead of doing something like this: for i in {1..4}; do ip a s p4p${i}; done can I just do something similar to: ip a s p4p* and achieve the same effect?
According to ip addr help: [...] ip addr {show|save|flush} [ dev STRING ] [ scope SCOPE-ID ] [ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ] [up] [...] You can use: ip addr show label p4p\*
Does ip command support wildcards?
1,591,436,750,000
For example, I may have the following on my clipboard: /Users/matt/widgets/file.txt And I want to change directory to: /Users/matt/widgets cd doesn't work: $ cd /Users/matt/widgets/file.txt bash: cd: /Users/matt/widgets/file.txt: Not a directory What simple (i.e. easy to type) change can I make to make this easy?
If you're OK with front-loading the effort in order to make subsequent runs easier, you could create a function (name it whatever makes sense to you): function cdfile { cd -- "$(dirname $1)"; } Save such a definition to your ~/.bashrc file. Then, each time you have a file path that you wanted to cd to, you could cdfi...
What's the easiest way to cd to the deepest directory on an absolute path to a file?
1,591,436,750,000
How can I write grep pattern in multiple lines, inside bash script? Like that: grep -o -P ' (?!<.*?(?<!(href))=") https?:\/\/(?!(www\.example\.com)).*? (?=(">)) ' input.txt When I wrote php programs, I could do so. Now tried this in the bash script - it doesn't work. It is very unhandy write all in on...
grep takes newlines as separating different patterns. But you could save the pattern in a variable, and then remove the whitespace before passing it to grep: $ ws=$' \t\n' $ pat=$'a b\nc' $ echo abcd | grep "${pat//[$'\n\t ']}" abcd (Didn't test with anything more complex.)
grep - the multiline pattern writing
1,591,436,750,000
I learned about the command line command test and read a few examples. One of them was obscure to me: test 100 -gt 99 &amp;&amp; echo "Yes, that's true." || echo "No, that's false." I understand it to this point: test 100 -gt 99 evaluates whether 100 is greater than 99 echo "Yes, that's true." || echo "No, that's...
&amp; doesn't mean anything to test, it's the HTML entity for the ampersand &, which has a special meaning in HTML so it cannot be presented as-is. Where ever that snippet came from, the presentation is broken. Decoding that character, the line should be test 100 -gt 99 && echo "Yes..." || echo "No..." && and || sti...
What is the meaning of &amp with regard to the test command?
1,591,436,750,000
A very odd situation. If I enter into interactive commands - in this case tasksh and nslookup I cannot type whitespace. For example: tasksh> add "my new task" becomes tasksh> add"mynewtask" and does not work, naturally. I thought maybe this is something to do with tasksh but then I checked with nslookup in interact...
The most likely explanation is that you've accidentally bound Space to a command that has no visible effect in one of your configuration files. Check your shell initialization files for stty commands. That will directly affect at least programs that rely on the terminal's primitive line editor, and may indirectly affe...
I cannot type space in interactive command mode
1,591,436,750,000
I have a logfile with the following format: Jul 13 21:47:41 192.168.100.254 "user from 192.168.100.101" I need to remove ALL lines that contain IP's in the 192.168.x.x range but only if they appear in the 4th column. I also need to exclude 3 IP's from the 192.168.x.x range. Lets call these 192.168.125.100 192.168.1...
Try: awk '{f=1} $4 ~ /^192.168/{f=0} $4 ~ /192.168.(125.100|126.100|155.240)/{f=1} f' file Example Consider this test file: $ cat file Jul 13 21:47:41 192.168.100.254 "user from 192.168.100.101" Jul 13 21:47:41 192.168.125.100 "user from 192.168.100.101" Jul 13 21:47:41 192.168.126.100 "user from 192.168.100.101" Jul...
remove lines that contain IP range from specific column while making exclusions to range
1,591,436,750,000
I am having issues with the part of the following script where it takes the inputted image and checks its dimensions. If it's not a certain dimension then it resizes the image. My issue is what would I put inside the if-block to check that using ImageMagick? My current code: #Change profile picture f(x) #Ex. changePr...
First, unlikely you have 96x96 existing picture, so most of the case you need to convert. You don't have to identify and compare the dimensions. Don't trust extension of filename, .png doesn't means it's a PNG image. Test command and then install is an unnecessary checking and not portable (apt-get, dnf, ... etc). An...
How do I grab image dimensions using ImageMagick cli?
1,591,436,750,000
I want to excecute the following command over a ssh connection: tmpValue=$(cat /var/run/jboss-as/jboss-as-standalone8.pid) && top -b -U jboss -n 1 |grep $tmpValue |awk '{print $9}' This command is working on my target machine. Now I want to use this command from a different machine and execute it via ssh, so what I...
It might be easier to simplify the command so that you have fewer special characters on which the shell might choke: ssh jboss@myTargetServer 'ps -p $(cat /var/run/jboss-as/jboss-as-standalone8.pid) -o %cpu= 2>/dev/null' The trailing 2>/dev/null throws away the error text in the event that the PID file either cannot ...
execute command over ssh connection [duplicate]
1,591,436,750,000
I have a small test.sh script as follows: #!/bin/bash read -e -p "Enter a Directory: " directory echo $directory Here's what happens when I run it: $ ./test.sh Enter a Directory: ~/A\ Directory/ /Users/<username>/A Directory/ I want to be able to keep the escaped space inside that variable so that the program outpu...
You could try like this: Example 1: Your answer. #!/bin/bash read -e -p "Enter a Directory: " directory new_directory="$(echo $directory | sed 's/ /\\ /g')" echo $new_directory Example 2: If you are going to cd script output wrap it with double quote. #!/bin/bash read -e -p "Enter a Directory: " directory new_directo...
How to pass directory with escaped space to variable?
1,591,436,750,000
I have a big file >fid|29290408|locus|VBIEntCas2262_0001| Phosphoglycolate phosphatase (EC 3.1.3.18) [Enterococcus casseliflavus EC20] gtgagaaagaaagtactttttgatttagatggaacgatcattgattcgagtgaaggaatc tatggatcgattcaatatgcgatggaaaaaatgggaaaagagcaattagcgcaagacgta ctgcggagctttgtggggccgcctttgattgaatccttccgtggcttgggcttcgat...
You can use this command: awk '{print $1}' filename > newfile where filename is the name of the original big file and newfileis the file that will get the results.
split line based on space and delete the second part
1,591,436,750,000
I was reading the manual pages for the package moreutils but I did not understand the page for zrun. My manual page is almost the same as the die.net one: ZRUN(1) ZRUN(1) NAME zrun - automatically uncompress arguments to command SYNOPSIS ...
Here's an example; $ cat >afile This is a file line2 line3 $ cp afile bfile $ gzip afile $ ls -l total 8 -rw-r--r-- 1 usera usera 48 2014-02-19 13:24 afile.gz -rw-r--r-- 1 usera usera 27 2014-02-19 13:24 bfile with grep $ grep line * bfile:line2 bfile:line3 with zrun $ zrun grep line * /tmp/dpQH01hY51-afile:line2 /t...
Can you provide an example use for `zrun`?
1,591,436,750,000
I have an image Image.png. How do I use the ImageMagick command convert to make this file into a Image.jpg file with the following requirements: File size is 200~500 kb. Resolution in not less than 450 dpi Image size 35 x 45 mm Edit: These are the exact requirements for making some documents through electronic gover...
The command convert Image.png -resize 620x797 -quality 1 Image.jpg meets your claims. However PNG is lossless compression and JPG is lossy, so you can compress as much as you want, but the result may not meet your needs. How to figure it out: 450 dot per inch means 450 pixel per 25.4 mm to get the width: 450*35/25.4...
Convert image with imagemagick command line convert tool
1,591,436,750,000
I have fired an ls -1 command that runs and displays a long list of values. When the command ends I can not see the output which is outside the screen vertical length. How can I see those previous entries ? Is there a way to see the output progressively like : Display first 15 rows User hits a keystroke. Then displa...
You can pipe the output of ls to pipe as follows $ ls | less Then you are able to use less to browse the output, for example with Page Up and Page Down. You can exit less by pressing q. Type man less to find out more ways to scroll the output.
How can I see output from a command progressively?
1,591,436,750,000
For some reason a while back, the behavior of my command line changed, and I don't know why. Using OSX, now Mountain Lion(although this behavior was present before the switch). Using standard terminal, I would expect back some results from ps, but I get an error: $ ps aux |grep 'asdf' grep: asdf: No such file or dire...
Does it happens when you login as another user? Check output of "set ; env; alias". Post it you can't find a problem.
ps aux |grep 'asdf' grep: asdf: No such file or directory
1,591,436,750,000
I intended to delete all the backup files in a directory, so I was going to type rm *~ in the terminal. Unfortunately, I hit the Enter before hitting the tilde and unhappy things happened. Although, I've recovered all deleted files I really don't want it to happen again. Could I forbid the execution of such a command ...
I am not a fan of overriding built-in commands, but in my .bashrc (part of Tilde, my "dot files") I explicitly do this: alias rm='rm -i'; This makes rm ask for permission before deleting. It has saved me a few times. You can always override with rm -f.
how to forbid a command without a permission
1,591,436,750,000
I am on a Ubuntu machine. I have make a directory under root directory, by: $ sudo mkdir /hello $ sudo mkdir /hello/bye Then I mount tmpfs with size 1024M to /hello/bye by: $ sudo echo "tmpfs /hello/bye tmpfs size=1024M,mode=0777 0 0" >> /etc/fstab $ sudo mount -a In future , How to clear /hello/bye (tmpfs) ...
If by clear you mean delete all files in there, it's like any other directory: rm -rf /hello/bye/* If you mean unmount the tmpfs partition simply do: umount /hello/bye Having put the line tmpfs /hello/bye tmpfs size=1024M,mode=0777 0 0 in your /etc/fstab, that partition will be automatically mounted at ever...
clear tmpfs in my case
1,591,436,750,000
Previously, I asked this question about how to suspend Linux after a set amount of time. I would like to ask a similar question. Supposing I have a USB device attached to my system (OS = Fedora 13), are there commands that can: detach the USB device and, after detaching it, shutdown the system after a specified inter...
I assume by USB you mean a pendrive or external harddisk mounted to your file system. You "detach" this by unmounting the device. For that you will have to use the umount command. You can use the device or the mountpoint, for example: umount /dev/sdb1 or umount /mnt/usb See man umount for more details. For shutting do...
How can I shutdown after unmounting a USB device from the command line?
1,591,436,750,000
I have been using unix systems the majority of my life. I often find myself teaching others about them. I get a lot of questions like "what is the /etc folder for?" from students, and sometimes I have the same questions myself. I know that all of the information is available with a simple google search, but I was wond...
tree --info will do what you want. You can create .info txt-Files that contain your remarks about certain files and folders or groups of files and folders (using wildcards). tree --info will then show them in the directory listing. Multi-line comments are possible. There is also a Global info file in /usr/share/finf...
Is there a way to add a "description" field / meta-data that could viewed in ls output (or an alternative to ls)?
1,591,436,750,000
In zsh, globbing kicks in when using wildcard characters ? or * like this: ls file?.txt However I would like to disable globbing in a case like this: youtube-dl https://www.youtube.com/watch?v=QIysdjpiLcA I can work around this by putting the argument in either single or double quotes (' or "). Can I somehow configu...
If you put noglob in front of a command, no globbing is done. noglob youtube-dl https://www.youtube.com/watch?v=QIysdjpiLcA To disable globbing for a particular command, make it an alias. alias youtube-dl='noglob youtube-dl' With URLs, this helps with ?, but not with &. There's no way to disable the interpretation o...
zsh: disable globbing for certain commands or patterns?
1,591,436,750,000
Apologies for any duplication, but most questions I've come across relate to getting a specific value from a field in a row, or using tail to get n tailing lines from a file, where n is known a priori. I'm looking to find a row where a value is matched, and then get all fields in that row AND all following rows. Detai...
In awk, $r would refer to the value of the rth field, rather than the value of r itself. Your solution should work if you just replace $r by r : awk -F, -v r=$SID '{ if (NR >= r) print $0}' data.csv or (more idiomatically, using the default print action) awk -F, -v r=$SID 'NR >= r' data.csv However there's really n...
Find row containing string, then return that row and all following rows of text file with awk
1,591,436,750,000
How can I display the number of registered users on the system who have their home directory in /home and simultaneously have Bash Shell as the command interpreter?
You could just grep the /etc/password file for lines that have :/home (so a field that starts with /home), then more non-: characters and only one more : before the end, which should be followed by /bin/bash: $ grep ':/home/[^:]*:/bin/bash' /etc/passwd terdon:x:1000:1000::/home/terdon:/bin/bash bib:x:1001:1001::/home/...
Display the number of registered users
1,591,436,750,000
I have a small snippet which gives me some ips of my current network: #!/bin/bash read -p "network:" network data=$(nmap -sP $network | awk '/is up/ {print up}; {gsub (/\(|\)/,""); up = $NF}') it returns ip addresses like this 10.0.2.1 10.0.2.15 and so on. now I want to make them look like this: 10.0.2.1, 10.0.2.15,...
If you need exactly ", " as separator, you could use echo "$data" | xargs | sed -e 's/ /, /g' or if you are enough with comma as separator, then echo "$data" | paste -sd, -
separating an array into comma separated values
1,591,436,750,000
Background CLion's remote project feature currently doesn't support FreeBSD as a remote host OS, but I want to do some hacking and see if it works. By reading the log file, I think I have spotted (one of) the issue. 2019-04-10 00:13:55,850 [2221079] DEBUG - #com.jetbrains.ssh.nio - UnixSshFS:: SshCommandRunne...
stat -f 0%i%HT%HT%HT%HT%a%m%z / on FreeBSD should be pretty similar to stat --printf %W%i%F%F%F%F%X%Y%s / on Linux, with the exception that %HT will expand to Directory instead of directory, as %F does on Linux. I just inserted a 0 instead of %W (birth time), since on most Linux systems that will be 0 (unknown). Rep...
Translating Linux stat(1) command into BSD stat(1) command
1,591,436,750,000
I have a file (comma separated) on a Linux system with 3 columns. I want to start new column after every 4th row. Input: col1,col2,col3 1,disease1,high 1,disease2,low 1,disease3,high col1,col2,col3 2,disease1,low 2,disease2,low 2,disease3,high col1,col2,col3 3,disease1,low 3,disease2,low 3,disease3,low Expected ...
With awk: awk '{a[NR%4] = a[NR%4] (NR<=4 ? "" : ",") $0} END{for (i = 1; i <= 4; i++) print a[i%4]}' < input.txt
How to start a new column after every nth row?
1,591,436,750,000
I have a directory with a lot of mp3 files, and I need a simple way to find the accumulated duration for them. I know that I can find the duration for one file with ffmpeg -i <file> 2>&1 | grep Duration I also know that I can run this command on all mp3 files in a directory with the command for file in *.mp3; do ffm...
You can get exactly the duration in seconds, then sum them with bc: for file in *.mp3;do ffprobe -v error -select_streams a:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 "$file";done|paste -sd+|bc -l Convert this number to HH:MM:SS format by yourself. e.g. https://stackoverflow.com/a/12199816...
How to find accumulated duration on several mp3 with command line?
1,591,436,750,000
I have some logic for executing java projects; it all works in the terminal console when I type it, but not in the cron scheduler: run 1st microservice and get variable from POST request: java -jar /root/parser-0.0.1-SNAPSHOT.jar value=$(curl -d '{"query":"java-middle", "turnOff":true}' -H "Content-Type: application/j...
Each cron job is a unique shell instance that does not share state with any other cron job, so 51 09 * * * value=42 sets value only for that job, which then exits, and value is then lost. A shell session, by contrast, maintains state over successive lines. You will need a single cron job that runs all that code, or s...
cron not executing command with variable
1,591,436,750,000
I have read the answer to a post, it suggest to use: systemctl set-default multi-user.target to log in command line mode. It works fine, except before login, it seems CentOS has boot into the graphical mode which make the start up process quite slow. See the following picture: I have minimal installed CentOS before,...
To get rid of the pre-boot GUI you have to remove the rhgb option in the grub options. If you also want the kernel messages during boot, you also have to remove the quite option of the kernel append line. To do so, edit the file /etc/default/grub with a text editor of your choice and adopt the GRUB_CMDLINE_LINUX. If...
CentOS boot without GUI has actually started gui before login
1,591,436,750,000
I'm curious if anyone can help me with what the best way to protect potentially destructive command line options is for a linux command line application? To give a very hypothetical scenario: imagine a command line program that sets the maximum thermal setting for a processor before emergency power off. Lets further ...
I'm assuming you're looking at this from the POV of the utility programmer. This is broad enough that there isn't (and can't be) a single right answer, but some things come to mind. I think most utilities just have a single "force" flag (-f), that overrides most safety checks. On the other hand, e.g. dpkg has a more f...
How to protect potentially destructive command line options?
1,517,853,531,000
I want to add a tab character to seperate numbers and letters of my file: 71aging 1420anatomical_structure_development 206anatomical_structure_formation_involved_in_morphogenesis 19ATPase_activity 46autophagy 2634biological_process So now it would look like this: 71 aging 1420 anatomical_structure_development 206 ...
Below one is the sed one liner for your requirement sed "s/^[0-9]*/&\t/g" filename output 71 aging 1420 anatomical_structure_development 206 anatomical_structure_formation_involved_in_morphogenesis 19 ATPase_activity 46 autophagy 2634 biological_process
Adding a tab between every number and letter
1,517,853,531,000
I followed the posts on stackexchange websites to parse command line arguments. My program only parses long arguments and all arguments are mandatory. Here is what I have done: getopt --test > /dev/null if [[ $? -ne 4 ]]; then echo "getopt --test failed in this environment." exit 1 fi function quit { echo...
I think what is happening is that what you intend to be your first parameter is being interpreted by getopt as an optstring. The beginning of the getopt man page lists three synopses. You seem to be using the second: `getopt [options] [--] optstring parameters` Notice how after the -- the first item is not parameters...
util-linux's getopt ignores first argument
1,517,853,531,000
I struggle to understand the effects of the following command: yes | tee hello | head On my laptop, the number of lines in 'hello' is of the order of 36000, much higher than the 10 lines displayed on standard output. My questions are: When does yes, and, more generally, a command in a pipe, stop? Why is there a mism...
:> yes | strace tee output | head [...] read(0, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192 write(1, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192 write(3, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192 read(0, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny...
When does piped command stop?
1,517,853,531,000
I would like write a batch script that checks used or available memory allow me to run commands if available memory less than X mb. I googled but page they refer didn't work for me I am using centos 7 basically I would like to do if availablememory < 26000m do command=forever stopall do command=pkill -f checkurl.php ...
if [ $(awk '/^MemAvailable:/ { print $2; }' /proc/meminfo) -lt 123456 ]; then : do someting done
batch script run command if available memory less than X mb
1,517,853,531,000
I want to open eclipse through terminal and i am able to do it, but when when eclipse starts it asks for the workspace directory attached the screenshot,and then there i have to specify it, i dont want this. As i pass the eclipse command in the terminal, i want to pass the workspace directory along with the eclipse c...
The following should do: eclipse -data /home/user/path/to/workspace Here a list of all eclipse command line arguments. Alternatively, if you anyhow only have one workspace, you could select a workspace in the dialog and check the box "Use this as the default and do not ask again".
open eclipse from a terminal and pass a workspace to open
1,517,853,531,000
While using applications (such as a database front end, or a programming language) from within a terminal, what's the best way to store the command history (of commands issued within the applications). E.g. I start python from the shell and issue a bunch of python commands. I'd like those stored somehow. I know this...
Ok, found it at long last. It is rlwrap To copy paste from its man page: rlwrap runs the specified command, intercepting user input in order to provide readline's line editing, persistent history and completion
Command history in terminal applications
1,517,853,531,000
I want to parallelize spliting of many directories into subdirectories using parallel or using another tool or method. E.g. I have 1 000 000 directories with content, but it's too much for one directory, so I want to create 10 dirs in the main dir and move in each of them 100 000 original dirs. I also want to use sor...
This problem deals with heavy IO. I doubt that parallel is really useful in this situation. Anyway I suggest that you consider a "traditional" approach: mkdir dir_{1..10} ls -tr | nl | \ awk '$2 !~ /^dir_/ {i=1+int($1/100000); print $2 | "xargs mv -t dir_"i}' where ls -tr | nl sorts the directories by date an...
Use parallel to split many directories into subdirectories or parallelize this task
1,517,853,531,000
I want to grep stuff out of an output file. For example ab and cd. The file looks like: asdf ab hgr cd ab asdsda if I now grep for ab and cd after one another like for i in $@ do grep $i file done I get ab ab cd What I want though is ab cd ab Is there an elegant solution?
You get this result because loop first execute grep ab file and return all occurances of ab in first iteration and after this loop execute grep cd file and return all cd occurances in file. You do not need a for loop. Try this: grep -e "^ab$" -e "^cd$" file Or use -x option to select only those matches that exactly m...
grep for multiple arguments, but output them in order of appearance
1,517,853,531,000
I'm doing something wrong on the string comparison below. It works if I set a variable and compare that, but I can't copy the value to a string. Does anyone know what's wrong? $ if [ "$(lsb_release -i)" = "Distributor ID: RedHatEnterpriseClient" ]; then echo yes; else echo no; fi no $ lsb_release -i Distributor ID: Re...
In this case I suggest -is: if [ $(lsb_release -is) = "Debian" ]; then echo yes; else echo no; fi
Can't compare lsb_release result to string in Bash
1,517,853,531,000
I'd like to run a shell command on each line taken from STDIN. In this case, I'd like to run xargs mv. For example, given two lines: mfoo foo mbar bar I'd like to run: xargs mv mfoo foo xargs mv mbar bar I've tried the following strategies with ruby, awk, and xargs. However, I'm doing it wrong: Just xargs: $ echo "m...
echo "mbar bar\nmbaz baz" | xargs mv With xargs you should use the -t option to see what's going on. So in your above case if we were to invoke xargs with -t, what do we see: mv mbar bar mbaz baz So obviously it's not correct. What happened was that xargs like a hungry crocodile, ate all the args fed to it via the pi...
How do I loop over the lines in STDIN and run a shell command?
1,517,853,531,000
I want to make a python script run on a socket of server in LAN. I wrote a number guessing script and i want to make it run on socket for other clients to play with it by connecting to port (say 1234). I know to achieve this by socket programming from python. But this question is to ask as to why this fails? ncat 192....
Solution You are trying to listen on the port 1234, and to connect to machine with the IP 192.168.1.108 in the same time. You can't do that, you either listen for the connection using this : ncat -lvp 1234 -e "/usr/bin/python3.5 number_game.py"` or you initiate the connection to the desired machine using this : nca...
Runnning a python script on a socket with ncat?
1,517,853,531,000
I am on a system which deletes files which haven't been modified in 30 days. I need some way to preserve important files by marking them as being recently modifed. What is the best way I can do this? Something like for d in *; do; cat $d > $d ; done
cd to that directory, then use this command to mark only the files : find . -type f -exec touch {} \; or this command to mark even the directories : find . -exec touch {} \; After the execution, the files (and folders if you choose the 2nd command) will be marked that they were just changed, and their content won't ...
recursively mark all files in a directory as modified without changing file content
1,517,853,531,000
I have a tabular file in which the first column has IDs and the second one has numeric values. I need to generate a file that contains only the line with the largest score for each ID. So, I want to take this: ES.001 2.33 ES.001 1.39 ES.001 119.55 ES.001 14.55 ES.073 0.35 ES.073 17.95 ES.140 ...
Depending on the type of data, sorting may take a long time. We can get the result without sorting (but using more memory) like this: awk 'a[$1]<$2{a[$1]=$2}END{for(i in a){print(i,a[i])}}' infile
Filtering the line with the largest value for a given ID
1,517,853,531,000
I'm trying to pass a windows command into a linux netcat shell and then read back the output. So far I have: cat <( printf 'ipconfig\n' )| nc -v 137.148.70.243 443 Which when copied and pasted into my pretty linux terminal gets the ip info from the connected windows machine. However, when I try to call the same comm...
Your problem is that you are invoking sh and not bash for your script in the shebang line. The syntactical convention of <(command) is a bashism that does not exist when invoked via sh, which emulates the POSIX shell (if /bin/sh is a symlink to /bin/bash).
Command works when copied and pasted but not in a bash script?
1,517,853,531,000
Is there a way to actually execute results from a shell command, instead of using them as arguments to another command? For instance, I'd like to run '--version' on all executables in a folder, something like: ls /usr/bin/ | --version I've found a way using find/exec: find /usr/ -name valgrind -exec {} --version \; ...
Try doing this : printf '%s\n' /usr/bin/* | while IFS= read -r cmd; do "$cmd" --version; done
Execute stdout results
1,517,853,531,000
I am writing a shell script to auto-deploy a program with Jboss-cli, in linux ubuntu. I need to open the jboss cli interface and execute some commands but I want to do this automatically. what it looks like cd /opt/jboss/bin ./jboss-cli.sh --connect the above line open the jboss command line. I would like to be able...
If jboss-cli.sh reads from standard input, you can pipe the command to it: echo 'undeploy FlcErp.ear' | ./jboss-cli.sh --connect To execute multiple commands, you can use multiple echo commands. { echo 'undeploy FlcErp.ear'; echo 'other gommands'; echo 'go here'; } | ./jboss-cli.sh --connect but a here-doc is usuall...
How to pass Command to program open in shell?
1,517,853,531,000
In windows you can undo an operation if you press CTRL+Z. E.g. you delete a file in the gui then press CTRL+Z and the file will be restored and appears in the folder again. Is there something similar in linux but with commands?! E.g. i accidentially unzipped a file, and i want to undo the operation (all files should ...
A short answer is no. There is no "undo command" on GNU/Linux terminals. Although lots of commands have an inverse operation, like rename, compress, decompress, etc.
Undo last command possible? [duplicate]
1,517,853,531,000
I want to copy a text file to a directory with multiple names with curly braces: cp /path/to/file/a.txt /path/to/file/{b,c,d}.txt But it gives me the error: target '/path/to/directory/d.txt' is not a directory
for i in {b,c,d}; do cp /path/to/directory/a.txt /path/to/file/$i.txt; done
copy a file to a destination with different names
1,517,853,531,000
What is the meaning of the ? sign in the following command? find /foo/path -name \?
The ? is part of a mechanism called "pathname expansion" in the shell. Colloquially, the shell mechanism is called "globing". The basic glob makes use just of three characters: * ? and [ that build "patterns". An asterisk * means: Any character in any quantity (any string). A question mark (?) means: Any characte...
find: meaning of the \? sign as a value of the name parameter
1,517,853,531,000
I have a directory where there are multiple folders, each of folder contains a .gz file. How can I unzip all of them at once? My data looks like this List of folders A B C D In every of them there is file as A a.out.gz B b.out.gz C c.out.gz D d.out.gz
This uses gunzip to unzip all files in a folder and have the ending .out.gz gunzip */*.out.gz This will "loop"* through all folders that have a zipped file in them. Let me add an example: A a.out.gz B b.out.gz C c.out.gz D d.out.gz E e.out Using the command above, a.out.gz b.out.gz c.out.gz d.out.gz will all get un...
gunzip multiple files
1,517,853,531,000
I am surprised to see the a2p utility installed by default in my Linux distribution. a2p is a command line utility that converts an Awk program from standard input to a perl program that it outputs to standard output. Why would I ever want to convert an Awk program to a Perl program when I have an Awk interpreter ins...
You might want to use these tools to increase the efficiency of perl scripts. You would want to do this if you had a larger perl program and you wanted to integrate the functionality of an awk script without calling a subprocess. You would call a2p and integrate the generated code into an existing perl script. There'...
Why is a2p (Awk to Perl translator) installed by default? Why would I want to convert Awk to Perl? [closed]
1,517,853,531,000
I want output like this: name size and hash: myfile.txt 222M 24f4ce42e0bc39ddf7b7e879a mynewfile.txt 353M a274613df45a94c3c67fe646 For name and size only I have ll -h | awk '{print $9,$10,$11,$12,$5}' But how can I get hash for every file? I tried: ll -h | awk '{print $9,$10,$11,$12,$5}' | md5sum But I get only one...
You should not parse ls, instead use this: for f in * .*; do [ -f "$f" ] && \ printf "%s %s %s\n" "$f" $(du -h -- "$f" | cut -f1) $(md5sum -- "$f" | cut -d' ' -f1) done The for loop runs trough all files and directories in the current directory. [ -f "$f" ] checks if it's a regular file printf "%s %s %s\n" p...
md5sum for every file (with ll)
1,517,853,531,000
I accidentally typed in cd ` into terminal today and terminal didstrange things. It put a "> " signed on the next line followed by my cursor like it wanted some input. No matter what I entered continued to do the same thing until I terminated the command. Out of curiosity what happened? Was this a bug or a feature?
Answered here already... essentially Everything you type between backticks is evaluated (executed) by the shell before the main command
What is the effect of a lone backtick at the end of a command line?
1,517,853,531,000
If I search for multiple search strings in grep : usually just do: grep "search1\|search2" somefolder/*.txt but, what if I have 100 or more search strings? Can I say like this: grep "stringPattern.txt" somefolder/*.txt where stringPattern.txt is a file containing a list of words I need to search in *.txt.
grep has the -f flag exactly for this, use: grep -f patternfile somefolder/*.txt Where in the patternfile the search patterns are separated line by line.
How to search multiple search patterns from a file with grep
1,517,853,531,000
I got a git directory with plenty of python files(and some special file like .git). I'd like to copy only these python files to another directory with the directory structure unchanged. How to do that?
You will receive in destination_dir files with full path from / find /path/git_directory -type f -iname "*.py" \ -exec cp --parents -t /path/destination_dir {} + Other solution is rsync rsync -Rr --prune-empty-dirs \ --include="*.py" \ --include="**/" \ --exclude="*" \ ...
How to copy a directory with only specified type of files?
1,517,853,531,000
I'm trying to set up a for loop to run a process on pairs of files. The names of the files look like this 36_002_CGATGT_L001_R1_005.fastq.gz 36_002_CGATGT_L001_R2_005.fastq.gz 36_002_CGATGT_L001_R1_002.fastq.gz 36_002_CGATGT_L001_R2_002.fastq.gz 62_013_AGTCAA_L001_R1_003.fastq.gz 62_013_AGTCAA_L001_R2_003.fastq.gz...
If your shell supports the ksh ${var/search/replace} form of parameter expansion (ksh93, zsh, mksh, yash, bash): for r1 in *R1*; do r2=${r1/R1/R2} singles=${r1/R1/singles} trimmed1=trimmed$r1 trimmed2=trimmed$r2 sickle pe -f "$r1" \ -r "$r2" \ -o "$trimmed1" \ -p "$trimmed2" \ -s "$singles" done ...
for loop when matching both front and back of file name
1,517,853,531,000
There are two steps, that I would like to be run on one line: twinkle -c then call sip:[email protected] Here is the output: I wanted to perform these two steps on one line, I tried twinkle -c && call sip:[email protected] and twinkle -c call sip:[email protected] and twinkle -c ; call sip:[email prote...
I guess twinkle is accepting stdin and executing commands. So... printf %s\\n 'call sip:[email protected]' | cat - /dev/tty |twinkle -c ...should hopefully do it. If, instead, twinkle is one of those that reads /dev/tty explicitly, you can probably do... printf %s\\n 'call sip:[email protected]' | cat - /dev/tty | ...
Perform multiple commands on one line
1,517,853,531,000
I have a program that writes on the standard output a list of string values, one per line, and I would like to display in real time the list of distinct values along with the number of occurences for each one. For example, from this output: apple carrot pear carrot apple I need a command which generates this output (...
To expand on what @Bratchley said in the comments, if you have your program's output printing to a file, then you can run then watch command in the terminal to get near-real-time view of the output by including the -n flag like so: watch -n 0.1 "cat yourprograms.log | sort | uniq -c | sort -rn" Note: The ' -n ' flag...
Display distinct values of a list and number of occurences
1,517,853,531,000
How can this be done? I don't see any applicable option in the manual. I have positively checked that indentation breaks after ten million lines. You can check it like: $ (for i in `seq 0 10000000`; do echo "$i"; done) | nl I don't often generate so many lines, but I don't want it to break like it does. How can this ...
If you are suggesting that nl should buffer the entire input simply to measure the maximum required number, that is not in the spirit of stream filters at all. With rare exceptions (sort, for instance), core utilities try to process streams immediately -- especially as they may be used in a virtually infinite pipeline...
`nl` invocation soaking all input before numbering
1,517,853,531,000
I am using the tee command to output the compilation errors of a program into a file along with the terminal. gcc hello.c | tee file.txt This is the command I have used. The compilation errors are displayed on the terminal but they are not outputted in the file. How should I output the std errors into file?
With csh, tcsh, zsh or recent versions of bash, try gcc hello.c |& tee file.txt where |& instruct the shell to redirect standard error to standard output. In other Bourne-like shells: gcc hello.c 2>&1 | tee file.txt In rc-like shells: gcc hello.c >[2=1] | tee file.txt In the fish shell: gcc hello.c ^&1 | tee file...
Output Redirection
1,517,853,531,000
When I run env it shows 3 times /usr/bin under PATH. Same for every path under PATH title. For example - my scala bin directory shows 3 times. However, in my .bash_profile, it is written just one time. Also its not in .bashrc also. I need to make these 3 occurrences to 1, as even though I remove some path under PATH ...
OK..So I found the solution. Here is what I was doing :- 1) vi ~/.bash_profile 2) make changes3) source ~/.bash_profile to see those changes in effect . It seems for every editing and subsequent source command, temporarily keeps in current session. So , if i made changes 3 times and consequent source command, it shows...
env command shows 3 times same path
1,517,853,531,000
When copying multiple files from one directory to another is there a way to get bash to run through each file and ask for y/n? I vaguely remember adding something to the end of my command like 'ok?' to make it do this, but I can't find it anywhere!
I suspect that you’re remembering the -ok option to find.  Try something like find . -name pattern -ok cp {} other_directory \;
Prompt when copying multiple files?
1,517,853,531,000
Entering the following command prints duplicates as shown below. Not all lines print twice but some do. What gives? XXXX:~ XXXX$ man -k pid pid(ntcl) - Retrieve process identifiers pidpersec.d(1m) - print new PIDs per sec. Uses DTrace rwbypid.d(1m) - read/write calls by PID. Uses DTr...
I would assume since it's doing a regex search through the descriptions and the man page names that it's finding multiple hits and showing those pages multiple times. man -k printf Search the short descriptions and manual page names for the keyword printf as regular expression. Print out any mat...
Why the duplications in the command line output
1,517,853,531,000
How can I allow the traffic to be sent on the loopback device (lo)? What is the iptables command for it?
By your question, I presume that you either have default xtables policies of DROP on your chains, or you have explicit DROP/REJECT rules near the end of your chains. Any ACCEPT rules must come before these. Rule examples: -A INPUT -i lo -j ACCEPT # accept any traffic coming from lo. -A OUTPUT -o lo -j ACCEPT # accept ...
How is the loopback device traffic allowed?
1,517,853,531,000
Using a command line in terminal, I want to be displayed 1 if a program (for example Firefox or Chromium) is open and 0 otherwise. Edit: By "open", I mean "is running on the current machine and has a window open on the X server that I am seeing"
xwininfo -root -children | grep -q '"Firefox")' echo "$(($? == 0))" Would output 1 if there's a window of class Firefox connected to your X server (by any user from any machine). To limit to Firefox processes local to the machine where you're running that command: xwininfo -root -children | awk '/"Firefox"\)/{print...
How to know if a specific program is open
1,517,853,531,000
Let's say I have these series of commands mysqldump --opt --databases $dbname1 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1 mysqldump --opt --databases $dbname2 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1 mysqldump --opt --databases $dbname3 --host=$dbhost2 --user=$dbuser2 --password=$dbpass2 mysqldump ...
In your comment to @tink's answer you want seperate files in the .gz files: mysqldump --opt --databases $dbname1 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1 > '/var/tmp/$dbhost1.$dbname1.sql' ; mysqldump --opt --databases $dbname2 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1 > '/var/tmp/$dbhost1.$dbname...
Chaining mysqldumps commands to output a single gzipped file
1,517,853,531,000
I am looking for a website that contains a reference between how to do things on the command line in different unix OSs. I have seen such site before, I am just unable to find it. I know such site would be beneficial for the community.
The Unix Rosetta Stone (resource for sysadmins) might be the one you had in mind.
Cross Unix Command Reference
1,517,853,531,000
I need to read lines from STDIN and process them. I could do something like: <print lines to STDOUT> | while read line; do <process $line> done But this means that first all lines are printed and piped and then they are processed. I want to process every single line immediately, eventually before the next lines ar...
Your first attempt does work: tail -f temp.file | while read LINE; do firefox $LINE; done Then in another terminal, append to the temp file so that tail -f prints a line to STDOUT: echo 'google.com' >> temp.file Every time you do this, firefox will open a new tab.
Reading from STDIN and using data immediatly (while still reading) or opening a URL with zbar
1,517,853,531,000
I have 4 large USB devices with lots of backups collected over the years. I want to search for all .Trash folders and delete the contents on Fedora 17. I tried the following which failed:- # find . -name ".Trash*"-exec rm -rf {} \; find: paths must precede expression: rm Usage: find [-H] [-L] [-P] [-Oleve...
To expand on @rkosegi's answer: # find . -depth -name ".Trash*" -exec rm -rf {} \; Use -depth so that find doesn't try to descend the now deleted directory.
Search and delete .Trash
1,517,853,531,000
I know when you are in a man page it will display the file name at the bottom inside the man. How can I do the same thing manually?
I'm not sure it is possible to do everything you ask, because man(1) sends the formatted man page data to your pager program via a pipe. This would prevent showing a file name, for one thing. You can get a line count at least like so: Set your MANPAGER or PAGER environment variable to less. Add -M to your LESS enviro...
How can I display file info of a man?
1,517,853,531,000
How does one kill a printing job on centOS?
There are two command line interfaces to printing: In the BSD interface, use lpr to print, lpq to view pending jobs, lprm to cancel a job. In the System V interface, use lp to print, lpstat to view pending jobs, cancel to cancel ongoing jobs. There are several printing systems available for Linux and other unices. C...
How to kill a printing job on centOS
1,517,853,531,000
I have a question from this thread How to run a bash script by double clicking by entering the path in sudoers?. Since it was explained to me that it is unsafe to grant sudo privileges to the script.sh file, I decided to find a way to double-click the script.sh file without granting sudo privileges to the file itself....
EDIT Since you edited your comment to provide more information, I can now give you a complete answer. I verified with my friend who runs KDE plasma, and he says that the default behavior is that double-clicking a script on the desktop will launch it, provided that the executable bit is set. It doesn't launch it in a t...
How to run the command "sudo sh /path/to/script.sh" by double clicking?
1,517,853,531,000
I'm trying to setup a simple script to run on a cron job that runs in the background and notifies any open terminals of the outcome using the wall command. However when testing, I don't get any output at all. I'm using WSL Ubuntu and zsh via the Terminal app from Microsoft. Running tty and w returns the below, while w...
@EdgarMagallon is correct on two counts in the comments: This is related to the who command issue mentioned on Ask Ubuntu The owner of that answer (me) will ... ;-) Ok, so yes, the wall command does appear to use the same mechanism as who for determining the logged-in users and their terminals. So to get it to work ...
WSL2 Ubuntu - wall command
1,665,540,504,000
What specific syntax needs to be changed in the aws s3api cli command below in order for the bash shell to interpret the command properly? The environment is an ubuntu-latest GitHub runner executing a GitHub workflow using a bash shell. The command that is breaking in the GitHub Ubuntu runner is: aws s3api put-object-...
You just need to quote your arguments: aws s3api put-object-tagging --bucket s3.bucket.name --key filename.tar.gz \ --tagging "TagSet={Key=public,Value=yes}" The syntax {a,b,c} in bash indicates brace expansion: Brace expansion is a mechanism by which arbitrary strings may be generated. This mechanism is similar t...
bash unable to interpret cli command that uses curly braces in GitHub Ubuntu
1,665,540,504,000
The issue seems to stem from a misconfigured web server and has affected some domains I've came across in lynx and w3m, but links can access at least in some instances. Can this be resolved on the user-side? 403 Forbidden ------------------------------------------------------------------------------------- nginx
Try changing your text web browsers User Agent to something modern, e.g. Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0 on lynx this is done using --useragent option like lynx -useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0"
How to get around 403 errors on websites with text-based browsers?
1,665,540,504,000
In a Unix command line context I would like to compare two truly huge files (around 1TB each), preferable with a progress indicator. I have tried diff and cmp, and they both crashed the system (macOS Mojave), let alone giving me a progress bar. What's the best way to compare these very large files? Additional Details:...
You can use pv as a progress indicator, and pipe that to the shasum function to check the hash to see if they are identical. pv file1 | shasum 1.08MiB 0:00:00 [57.5MiB/s] [====================================>] 100% 303462e848ecbec5f8ab12718fa6239713eda1c6 - pv file2 | shasum 1.08MiB 0:00:00 [57.5MiB/s] ...
How to compare huge files with progress information
1,665,540,504,000
I can explain my problem with an example, let us take an example of man command, when we run this command in the terminal it opens the page in a new window, you cannot see what you had done before, in your terminal. How does one make that? I am working on a terminal application, I want it to work in a similar way when...
What you're asking about is called the alternate screen buffer, and applications switch to and from the alternate screen by sending ESC codes to the terminal. If your app is using an ncurses library, there will be functions to do this. If you want to do it from a shell script, you can use tput to send the appropriate...
Adding pages to terminal applications
1,665,540,504,000
I am trying to compile a file using a makefile but for some reason, I am getting an error in /bin/sh, I am getting the following: nvc FLAGS(LDFLAGS) black_scholes.o gaussian.o main.o parser.o random.o dcmt0.4/lib/random_seed.o timer.o util.o -o hw1.x /bin/sh: -c: line 0: syntax error near unexpected token `(' /bin/sh:...
The errors are in this line: $(CC) $LFLAGS$ (LDFLAGS) $(HW1_C_OBJS) -o $@ $LFLAGS is interpreted as $L followed by FLAGS; then $ (LDFLAGS) is interpreted as $ (the value of the variable whose name is a single space) followed by (LDFLAGS), which is why you get the FLAGS(LDFLAGS) output. To fix it, use $(CC) $(LDFLAGS...
Getting error in /bin/sh when trying to use a makefile
1,665,540,504,000
I'm a beginner in Linux world. Today I encountered something really weird. I used zcat command on a .zip file (this one, it's a manual for a motherboard: https://download.msi.com/archive/mnu_exe/E7A70v1.0.zip). It printed output to the terminal as expected. What surprised me the most is the fact that afterwards my pri...
The output contains (among other things) a valid escape sequence telling urxvt to print the current screen: ESC[i
Literally printing with zcat
1,665,540,504,000
I'm looking for a way of execute command which I can execute some command only under sub directory not command affect to current directory. find -name ":RUN" -exec rm -rf {} \; If I got a directory name is level0 which has sub directory the name is level1. and I run the above example command at level0 directory then...
When you sayfind   -something … you are effectively sayingfind . -something … i.e., searching starting in . (the current directory).  You want to search only in subdirectories, so dofind ./*/ -name ":RUN" -exec rm -rf {} ; This will not find subdirectories whose names begin with ..  If you want to include such directo...
How to handle with command to execute only it's subdirectory? [duplicate]
1,665,540,504,000
Synaptic has the option to search from different sources (Package name, description, name and description, etc)... But if you have a package installed in your system, Synaptic can show you what files are attached to that installation. So, what command can extract the list of all files generated by all installed packag...
You could search for filenames in packages with dpkg -S: -S, --search filename-search-pattern... Search for a filename from installed packages. $ dpkg -S '*.icc' colord-data: /usr/share/color/icc/colord/x11-colors.icc libgs9-common: /usr/share/color/icc/ghostscript/lab.icc libgs9-common: /us...
How to search for a file from the list of installed files of each package installed in the system
1,665,540,504,000
What command will pipe a man page to Kate text-editor without writing anything to the hard drive? I've seen examples that create a temp file (on the file system) and then open that tmp file with a graphical text editor. However, is it possible to accomplish this task in RAM alone, without writing to the file system?
kate can read from standard input with option -i or --stdin man foo | kate -i source: kwrite -h -i, --stdin Read the contents of stdin. Also, -l may be useful (for example, go to line one with -l1): -l, --line <line> Navigate to this line.
Pipe a Man Page to Kate Without Writing to Hard Drive
1,665,540,504,000
I have several lists with two fields - first field contain an URL, 2nd field an email-address (an account). The 2nd field is the same for all entries in a list. I concatenate the lists to one list, and sort it by the 1st field. Most entries are unique, but some are duplicates or triplicates (ie. the URL was in the l...
With sort + awk pipeline: sort -k1,1 file \ | awk 'url && $1 != url{ print url, acc } { acc = ($1 == url? acc FS:"") $2; url = $1 }END{ print url, acc }' OFS='\t' Sample output: url1 acct2 url2 acct1 url3 acct1 acct2 url4 acct2 acct3 acct5
List sorted on 1st field, how can I join 2nd field on lines where 1st field is the same?
1,665,540,504,000
This is a similar question to this one I want to do the word count but this time, using an array. For example, I have the following IPs inside a bash array called IPS. IPS=("1.1.1.1" "5.5.5.5" "3.3.3.3" "1.1.1.1" "2.2.2.2" "5.5.5.5" "1.1.1.1") If I read its contents: user@server~$ "${IPS[*]}" 1.1.1.1 5.5.5.5 3.3.3.3 ...
try: printf '%s\n' "${IPS[@]}" |sort |uniq -c |sort -rn |sed 's/^ *//' 3 1.1.1.1 2 5.5.5.5 1 3.3.3.3 1 2.2.2.2 related: Printing an array to a file with each element of the array in a new line in bash Why is printf better than echo?
Bash - sort and uniq on array
1,665,540,504,000
I am trying to calculate a PBKDF2 hash, but am getting inconsistent results. Message: Hello Salt: 60C100D05C610E8B94A854DFC0789885 Iterations: 1 Key length: 16 Expected hash: 584519EF3E56714E301A4D85F972B6B4 nettle-pbkdf2 gives a951d3cd9014e0c0 527000727c1e928a https://asecuritysite.com/encryption/PBKDF2z and Crypt...
nettle-pbkdf2 documents it uses HMAC-SHA256 as its pseudo-random function; the other two are using HMAC-SHA1. Nettle has a PBKDF2-HMAC-SHA1 implementation, but I'm not sure if you can easily get it from the command line. (HMAC-SHA256 is generally a better choice if you have the option; SHA1 should be avoided). (Of cou...
PBKDF2 not the same
1,665,540,504,000
I have a command which looks like this: cat PGC2.SCZ.1.dat | awk 'NR == 1 || $NF < 0.05/1783' so this part I guess means skip the first line awk 'NR == 1 but what does this refer to? || $NF < 0.05/1783' Thanks
NR means "number of record" and refers to the line streamed to awk. (By default every new, not empty line is a new record. One can define a different record separator RS. Then the term line isn't correct here anymore.) NF means "number of fields" and refers to the number of columns in the line. Due to the $ before the...
How to interpret Unix command?
1,665,540,504,000
I need a command that would echo the average CPU usage over the past 10 seconds in Ubuntu 18. Each of the following conditions must be met: It must be lightweight with a very small footprint, running a background script constantly writing to the filesystem is a no no. The value must account for number of cores automa...
The sysstat package provides sar, a system activity data collector. sar -u ALL 10 1 posts average cpu stats of the next 10 seconds since starting the command. The output is like Linux 5(...) 11/05/21 _x86_64_ (1 CPU) 17:22:35 CPU %user %nice %system %iowait %steal %idle 17:...
How to get the average CPU usage over the past 10 seconds in bash?
1,665,540,504,000
Suppose I want to do a search to find out if I have a file that matches the sha256 generated from the file test1.txtusing the command: sha256sum -b test1.txt I get as output: e3d748fdf10adca15c96d77a38aa0447fa87af9c297cb0b75e314cc313367daf * test1.txt So, I want to find the files that match the checksum generated i...
find . -type f -exec sha256sum -b {} + | grep -F 'e3d748fdf10adca15c96d77a38aa0447fa87af9c297cb0b75e314cc313367daf' This would calculate the SHA256 checksum for each and every file in or under the current directory. The grep at the end would extract the results of the calculations that match the checksum that you a...
Is it possible to search for a file using the checksum instead of the name? [duplicate]
1,665,540,504,000
When I install a LAMP server environment on Debians I use this code: apt-get upgrade lamp-server^ php-cli php-curl php-mbstring php-mcrypt php-gd python-certbot-apache -y If I add more php-X packages it becomes uglylically long. Is there a way to shorten it a bit like as follows? apt-get upgrade lamp-server^ php-cli|...
Yes, you can use bash brace expansion to generate the arguments with the same prefix. The correct syntax would be: apt-get upgrade lamp-server^ php-{cli,curl,mbstring,mcrypt,gd} python-certbot-apache -y
Debian: Remove redundant package terminology
1,665,540,504,000
I have this quite unusual condition here. I have a old linux system that has no sudo or su commands. I do not have physical access to this computer so I cannot login as another user. Linux kernel is 2.6.18-498 and the system is a red-hat 4.1.2-55. I can go to the /bin directory and can say for sure there are no su or ...
See if you have any remote login services running (in.telnetd, rlogind, sshd) and then run the appropriate login command to the localhost (127.0.0.1). For example if you have sshd then do: $ ssh [email protected] With telnet you'd run: $ telnet -l root 127.0.0.1 And with rlogin you'd run: $ rlogin -l root 127.0.0.1...
How to run command as a different user when there are no sudo or su commands
1,665,540,504,000
In the command line, I appended a directory to my PATH without exporting it: $ PATH='$PATH:/home/user/anaconda3/bin' For some reason this has overwritten the PATH environment variable but I'm not sure why this happened. The PATH above is still a colon separated list of directories like it should be so what's the probl...
Single quotes suppress parameter expansion. $ foo=42 $ echo '$foo' "$foo" $foo 42
Why did PATH='$PATH:/Path/to/bin' overwrite my PATH?
1,665,540,504,000
I am pasting multiple commands into my command line and would like each line to execute and output the results sequentially. I am pasting my input: cat type_of_record.txt | grep 'type_of_record_new creating' | wc -l cat type_of_record.txt | grep 'type_of_record_modification found 1' | wc -l cat type_of_r...
Just paste your clipboard into a heredoc: $ sh -v << EOF > cat type_of_record.txt | grep 'type_of_record_new creating' | wc -l > cat type_of_record.txt | grep 'type_of_record_modification found 1' | wc -l > cat type_of_record.txt | grep 'type_of_record_modification found 0' | wc -l > cat type_of_recor...
How do i execute multiple commands sequentially on the command line?
1,665,540,504,000
I'm using OSX terminal and trying to extract specified text of log file by regex. awk version is GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2) Copyright (C) 1989, 1991-2018 Free Software Foundation. my trying operation is $gawk '/123/ BEGIN{RS="DEBUG"; FS="\n"}{print $0"\n"}END{}' ./app_108_utf8_T2.log > ou...
I’m guessing you want to run gawk 'BEGIN{RS="DEBUG"; FS="\n"} /123/{print $0"\n"}' ./app_108_utf8_T2.log > output.txt BEGIN defines the block of instructions which run at the start of the process, and /123/ defines the block which runs when the “123” regular expression matches the current line. You can’t specify both...
How to solve this syntax error of gawk (GNU awk) on OSX terminal?
1,665,540,504,000
In zsh, how do I refer to the grandparent directory with ... rather than ../.., and so forth? I used to have this in oh-my-zsh and prezto. PS. Ideally, M-3 . should yield ../../...
The following code does the trick: rationalise-dot() { if [[ $LBUFFER = *.. ]]; then LBUFFER+=/.. else LBUFFER+=. fi } zle -N rationalise-dot bindkey . rationalise-dot bindkey -M isearch . self-insert
Changing to ancestor directory without typing all the dots and slashes
1,665,540,504,000
I have a file containing full path names of files an directories. From this list I would like to filter out any pathnames that reference directories so that I am left with a list containing only file paths. Can anybody think of an elegant solution?
while IFS= read -r file; do [ -d "$file" ] || printf '%s\n' "$file" done <input_file Would print the files that are not determined to be of type directory (or symlink to directory). It would leave all other type of files (regular, symlink (except to directories), sockets, pipes...) and those for which the type cann...
Filter directories from list of files and directories
1,665,540,504,000
The command 'ps' gives current status of the processes. Is there any way to find the status of a particular process in the past: say I would like to know the status of a particular process 48 hours before from now? I have a unit crashing and wanted to know the status of different processes during the exact time when t...
No, commands such ps and top show only the current status of processes. There's no way to know what the process status was in the past unless you already set up a monitoring system. For the future, you can set up atop to log process status. From its manpage: In order to store system- and process level statistics for...
Process status of the past time
1,665,540,504,000
I like using curl and the command line to process html pages. Relative urls are a pain. Is there some easy utility to make all relative urls absolute? Ideally this would look something like curlabsolute $URL | process
What you need is wget utulity: Let's say we need to download a simple web-page given by http://www.littlewebhut.com/articles/simple_web_page/. The command (the below used url is real, the command can be tested "as is"): wget -O simple_page -k http://www.littlewebhut.com/articles/simple_web_page/ -O (--output-documen...
Make all urls in a page absolute from the command line
1,665,540,504,000
I have a similar content in a file. I have a list of line numbers with me say 1,2, 4. Can feed all the required line #s Extract the contents between the first occurence of and last occurence of </book> Data: </p><p>abc</p></book><book><p style="text-indent:0em;">def</p></book><book><p>ghi</p><p style="text-indent...
1) Extract specific lines In your four-line example to extract the 1st, 2nd and 4th line would be easy by deleting the 3rd line: sed 3d file But your file is probably more complicated, so a more general solution would be to do sed -e 1b -e 2b -e 4b -e d file So for each line that should be kept you jump to the end o...
For a set of line numbers ...Extract content between first and last occurence of different patterns
1,665,540,504,000
Googling for this question gives a lot of answers based on PCIe. Unfortunately, I'm not looking for PCIe based answers at the moment. I have an older PC that still contains some PCI-X slots (y'know, like good old PCI but longer and faster). At the moment I have an Auzentech X-Meridian 7.1 2G installed in the PCI slot,...
Your card is running at 33MHz in 32-bit mode. For a 64-bit, 66MHz PCI-X device you’d see 66MHz+ in the Status line, and you’d also have a 68 capability section like Capabilities: [68] PCI-X non-bridge device Command: DPERE- ERO- RBC=512 OST=8 Status: Dev=03:04.1 64bit+ 133MHz+ SCD- USC- DC=...
How to see speed of PCI-X card?
1,665,540,504,000
I have hundreds of directories, inside each of them is a file with name report.ext and this file can contain a row like Beta score for best model 95.35 I would like to get a list of directories, where this file does exist, where it contain such row and where this row contains value greater than 95. Is this possible f...
The easiest is to look for those files and print their parent directory if their content match. For instance with something like: find . -name report.ext -type f -exec awk ' /^Beta score for best model [0-9.]+$/ && $NF > 95 { dir = FILENAME sub("/[^/]*$", "", dir) print dir nextfile }' {} + ...
How to list directories with specified file in them has specified content?
1,665,540,504,000
Is there a way to get a list of all commands that match a specific (case insensitive) pattern? So for example, I know the command (which might be an alias) I'm looking for contains "diag" or "Diag" but I'm not sure of the actual command. I'm currently on Ubuntu with Bash but am asking specifically on this site because...
Use compgen -c to get a list of all commands, you can also use it like: compgen -c dif to get a list of all commands started with "dif". Combine it with grep to get exactly what you are looking for: compgen -c | grep -i diag which looks for any commands containing "diag". use regex for more flexible searches: compge...
Find commands by partial name
1,665,540,504,000
Trying to install pass (password manager). I noticed that in my system (Ubuntu 14.04.4) another program called pass is already installed but I am sure that this is not password manager. pass --help returns Input format should be: ./pass inputfile min_window max_window false_num outputfile [-qnorm] [-nop] [-adju...
Use dpkg -S to search for what package owns the file: dpkg -S /usr/bin/pass My guess, based solely on the names of the expected command line options, is that your pass command is a command line version of Poisson Approximation for Statistical Significance (a bioinformatics tool). This tool has a web interface here (...
/usr/bin/pass and /usr/bin/pass2