date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,375,280,881,000
How can I make the next script to run when I'm using sh shell: #!/bin/bash bind '^[[3'=prefix-2 bind '^[[3~'=delete-char-forward bind '^[[1'=prefix-2 bind '^[[1~'=beginning-of-line bind '^[[4'=prefix-2 bind '^[[4~'=end-of-line
bind is a bash command, not an sh command. If you aren't using bash, the bind command won't be available. Depending on the platform, sh may be one of several shells. They all provide a common core for scripting. Plain sh hardly has any convenient features for interactive use; in particular, plain sh has no notion of k...
How can I make "bind" command to work in sh shell
1,375,280,881,000
I need to convert an RGB raw file into 3 files containing each the red, green and blue channel.
Have you tried the netpbm tools? This will work with R8G8B8 and other 8-bit RGB orders. For a width 100 height 200 RGB order raw file: rawtoppm -rgb 100 200 input.rgb > image.ppm ppmtorgb3 image.ppm You will now have 3 pgm format grey-map files, each suffixed .red .grn and .blu. These .pgm files are almost a raw bin...
Splitting RGB raw file into 3 files, one for each channel?
1,375,280,881,000
What tool in Linux can I use to merge multiple flv files ? Files are already in order, just put them altogether seamlessly
I didn't test the following yet, so see it just as some hints. You could use ffmpeg. From the manual * You can put many streams of the same type in the output: ffmpeg -i test1.avi -i test2.avi -vcodec copy -acodec copy -vcodec copy -acodec copy test12.avi -newvideo -newaudio In addition to the ...
Merge multiple flv files?
1,375,280,881,000
I have several video files in a directory and I want to convert all of them into other video formats. Is there any way that I can convert all of them in just one go using FFMPEG. I mean without having to make a shell script for doing so.
The easiest way would be to use a for loop of your shell of choice. This task is so simple, you can just use the prompt, there's no need to create a shell script. Here is the one-liner as an example for the widely-used bash (and compatible): for i in *.mkv; do ffmpeg -i "$i" … ;done
How to convert a group of video files using FFMPEG?
1,375,280,881,000
I am trying to create a file occurent within my /tmp directory of each file containing a speicific string. The problem is that the call to basename {} does not seem to work. Neither this, neither echo basename {}. grep -R 'mystring' . | cut -d: -f 1 | uniq | xargs -n 1 -I {} touch /tmp/`basename {}` Does anybody know...
try this: grep -R 'mystring' . | cut -d: -f 1 | uniq| xargs -n 1 -I {} -t -i ksh -c "touch /tmp/$(basename {})"
Inner function call with xargs parameters
1,375,280,881,000
QUESTION: Is there a Kerberos-friendly web browser usable via an SSH console? I have tried links but it does not seem to work with Kerberos (the webapp asks me for login/password even though I have a valid Kerberos ticket (which I got with kinit). CONTEXT: From my laptop I have command-line access to a server, and nee...
If you are connected to this server using SSH, you may use "ssh -x" then X will be automatically forwarded (and secured).
Command-line web browser with Kerberos authentication?
1,375,280,881,000
While I can find some scattered info on the topic, I can't seem to find a straight walkthrough (or even a definite answer)... Basically I'm too low on the totem pole to start sending plain-text e-mails. My company requires an HTML signature that includes the logo image. The problem is I'm fed up with GUI mail clients....
This is a huge hack, but somebody has already done the work for you. Edit: What if you attached your signature as an HTML file? mutt -e "set content_type=text/html" [email protected] -s "Hello" < mysig.html
Sending HTML with Mutt (or another terminal mail client)
1,375,280,881,000
I'm using the OSX application Terminal to work remotely on Amazon EC2 servers through SSH. Occasionally and seemingly randomly, my keystrokes are delayed. I've tried reconnecting, restarting Terminal, restarting my computers, etc... Nothing seems to solve the problem, and it comes and goes. I've tried other terminal...
It is your connection. SSH only displays what the remote server tells it to, so it'll only echo your keystrokes once the remote server receives and process them and tells the shell to print them.
What causes delay in my keystrokes on OSX's Terminal application?
1,375,280,881,000
I'm submitting to my website using cURL. I make cURL post it in timely fashion. In below code; first line is curl submit; second line is for queuing: curl -b cookies.txt \ -d title="$(sed '1,/sblmtitle/d;/slpstitle/,$d' sedut.html)" \ -d taxonomy%5Btags%5D%5B1%5D="$( sed '1,/sblmkategori/d;/slpskategor...
curl has no idea that it failed - it had well-defined input, it communicated with the server and got back a 200 OK response. Because of this, you can't rely on the exit code of curl (which is what && does). Instead, we have to use something else to determine success or failure, such as the output generated by curl. As...
Using "&&" is not effective for cURL submit form (don't execute second line if first line fails)
1,375,280,881,000
How do I clear the contents of a file before writing to it? For example: echo one > filename.tmp # filename.tmp now contains "one" echo two > filename.tmp # filename.tmp should now contain "two", not "one" and "two" My goal is: Start a listener $ nc -l 7007 > /var/tmp/test.log Send some data $ telnet localhost 700...
You need a separate program to clear and write the new file since nc doesn't offer that option. nc -l 7007 | while true; do while read line; do echo "$line" > /tmp/test done done You can save everything after the pipe in a separate script that accepts a file path. save-last-line.sh while true; do wh...
How to keep overwriting the contents of a file instead of appending to it
1,375,280,881,000
I would like to view files exactly like I can view proccess using pstree. So is there something like: treeview --maxdepth 2 that would give me what I need?
You can use the tree utility for this: tree -L 2
How do I view files as a tree structure?
1,375,280,881,000
I'm struggling to create a FAT-formatted a disk image that can store a file of known size. In this case, a 1 GiB file. For example: # Create a file that's 1 GiB in size. dd if=/dev/zero iflag=count_bytes of=./large-file bs=1M count=1G # Measure file size in KiB. LARGE_FILE_SIZE_KIB="$(du --summarize --block-size=1024 ...
It would seem to me you're trying to fit a file on a file system that doesn't have enough space – by design! You're basically saying "For a file that takes N kB, make a disk image exactly N kB in size". Where exactly is FAT going to store the file metadata, directory tables and volume descriptor? With FAT32, the stand...
Create FAT-formatted disk image that can fit 1G file
1,375,280,881,000
Every now and then I want to recycle a command sequence I recently used, after I adapted it. Let's imagine, yesterday I executed foo 42 bar with some strange arguments baz /my/most/beloved/folder Now today I need to something similar like foo -x 42 bar with some more strange arguments baz /my/most/hated/folder I can...
Foolish me! I got the answer elsewhere. What I described as perfect solution seems to exist since long ago, I simply always oversaw it and didn't find the right search terms: ctrlO executes the current command and brings you to the following line from the history. What a great feature. Gladly, of more than twenty peop...
How to edit and execute a couple of commands from shell history?
1,375,280,881,000
I'm writing an interactive shell utility (it's a bash script), and I would like to provide a man page for it. It's a script that I expect the user to download and put in their PATH, not something that should require superuser privileges. Any idea where I should put the manual page? For the moment I just put it next ...
As far as I know, there is no standard recommendation for a user-writable man page directory. The Filesystem Hierarchy Standard 3.0 refers to the XDG Base Directory Specification and the xdg-user-dirs specification regarding things within users' home directories, but neither of those has anything specific to say about...
What is the recommended user writable manpath?
1,375,280,881,000
With $ as my bash prompt and ⏎ symbolizing me hitting the enter key in the following example, how could I construct a command/alias foo so that $ foo bar⏎ would enter/input/pre-fill/type "bar" (or any other string I pass to the command) to the command line, so that I can modify "bar" before hitting Enter? E.g. $ bar ...
Here's a small and ugly solution, inspired by a perl solution to insert a string after each prompt, using TIOCSTI adapted to python: A bash function, e.g. for .bashrc inject () { (python -c "import fcntl; import termios; import sys with open('/dev/stdout', 'w') as fd: for c in ' '.join(sys.argv[1:]): fcntl.ioctl(fd,...
Command to inject string into command line, like a pre-filled command to edit before execution
1,375,280,881,000
I'd like to know if it is possible to repeat part of a command (which hasn't been executed yet) on the same line (i.e., chained). Let's say I want to execute this command mkdir -p /some/long/dest/path && rsync -azP /some/long/src/path /some/long/dest/path Is it possible to type only something similar to mkdir -p /so...
You could use the line editing function to grab the mkdir argument and paste it to the end of the line. (I use vi-style line editing so that would be very straightforward: ESC to enter editing mode, 0WW to jump to the mkdir path, yW to yank the path, and p to paste it afterwards. I assume there's an equivalent in the ...
Is it possible to repeat part of a string that hasn't been executed yet in bash?
1,375,280,881,000
Suppose I have a command like: foo() { echo a echo b >&2 echo c echo d >&2 } I use the following command to process stdout in terminal but send error via notify-send foo 1> >(cat) 2> >(ifne notify-send "Error") The issue i am having is, I want to view the stderr (in this case b d) as notify-send body...
With your try with "$(cat)" you're almost there, but you need this cat to read from ifne, not along ifne. In case of ifne notify-send "Error" "$(cat)", cat reads from the same stream ifne does, but not simultaneously. The shell handling this part of code can run ifne only after cat exits (because only then it knows wh...
notify-send with stderr in notification body if there is stderr
1,375,280,881,000
I am trying to add a new application shortcut in the command line which will load the terminal when you press Ctrl + Alt + T. I am using the xfconf-query utility to monitor xfce4-keyboard-shortcuts and the output I get when setting my shortcut via the Keyboard GUI is: /commands/custom/<Primary><Alt>t. I've been able ...
If the property doesn't exist, it's necessary to create it using the --create option (or the synonymous -n) as indicated in the error. The following worked for me... xfconf-query -c xfce4-keyboard-shortcuts -n -t 'string' -p '/commands/custom/<Primary><Alt>t' -s xfce4-terminal Note that it was also necessary to add t...
Creating XFCE4 Application Shortcuts from the terminal (CentOS)
1,375,280,881,000
Is it possible to use awk to calculate the average of each row (with different columns in each row). I have a file like the following, the first column is the names, and I like to calculate the average of each row and print the result in the last column of the input file: Input-file (data1.csv): EMPLOYEE1,0.395314,0.3...
Here's one way: $ awk -F',' -v OFS=',' '{ s=0; numFields=0; for(i=2; i<=NF;i++){ if(length($i)){ s+=$i; numFields++ } } print $0, (numFields ? s/numFields : 0)}' data1.csv EMPLOYEE1,0.395314,0.384513,,,0.389914 EMP...
Using awk to calculate average of each row with different number of columns
1,375,280,881,000
My use-case is that I want that whenever I copy something to CLIPBOARD, it is also saved in PRIMARY. It's mostly assumed that to copy something you need to select it so most of the time this is not needed. However, sometimes I just click the classic "copy to clipboard" button and get something to CLIPBOARD that it's n...
Here's a quick Python program to do so, using the PyGObject bindings for GTK. I'm not an expert in this, so this is just an example that works for me, using rpm pygobject2 on an old Fedora release. You will have to find the equivalent packages yourself. #!/usr/bin/python3 # copy clipboard to primary every time it cha...
What's a lightweight way to synchronize CLIPBOARD -> PRIMARY selections?
1,375,280,881,000
I use this command to get the name of my network interfaces and their mac address ip -o link | awk '$2 != "lo:" {print $2, $(NF-2)}' | sed 's_: _ _' out: enp2s0 XX:XX:XX:XX:XX:XX wlp1s0 YY:YY:YY:YY:YY and this one to get the IP: ip addr show $lan | grep 'inet ' | cut -f2 | awk '{ print $2}' out: 127.0.0.1/8 192.168...
In bash this works: paste <(ip -o -br link) <(ip -o -br addr) | awk '$2=="UP" {print $1,$7,$3}' but it relies on the ip output being in the same order for link and addr. To be sure, you could use join with sort instead: join <(ip -o -br link | sort) <(ip -o -br addr | sort) | awk '$2=="UP" {print $1,$6,$3}' In sh c...
how do i get interface name, ip and mac from active interface only (except lo)
1,375,280,881,000
In Terminal, how can set up a custom warning so that when I type a specific command like git pull origin master the command doesn't go through and I get a warning output like Did you mean git rebase origin/master? I've considered creating a bash script or simply using an alias in my bash profile but I'm not sure wha...
There is not any hooks for pre-pull but you might find this useful https://git-scm.com/docs/githooks#_post_merge Hooks in general are nice, if you did not know about them. As for alias you would have to create one for git, as in create a function in .bashrc or .bash_aliases and check if arguments are pull origin mast...
How to create a custom CLI warning
1,375,280,881,000
I have checked all the previous posts related to this, but I cannot find the way that I wanted to do. I have a file with some exponential numbers as below. I do not know which columns have exponential numbers. file1.txt 1 499 5e-29 0.33 1.35 46.65 5 999 0.4444 3e-6 0.556 89.444 many more lines I want to convert all t...
You can loop for all fields of each line. Testing for if the field is a numerical value ($i+0==$i) and (&&) if it contains the character e seems good. So we modify only these fields to decimals. Here using GNU awk sprintf function: awk '{ for (i=1;i<=NF;i++) if ($i+0 == $i && $i ~ /e/) $i = sprintf("%.10f", $i) } ...
Convert all exponential numbers to decimal numbers in a file in Linux?
1,375,280,881,000
Reading the documentation about the Linux file command. I have found this in the magic test description: Any file with some invariant identifier at a small fixed offset into the file can usually be described in this way. The information identifying these files is read from /etc/magic and the compiled magic file /usr/s...
Why this file should be compiled? I suspect it's for performance reasons. The magic database is not small. File would need to parse every human-readable magic source file, construct the structures it uses to detect file formats, compute the strength of every pattern and sort everything by that. This process could ...
What is the useage of the "compiled magic file" named on the "file" command man documentation?
1,375,280,881,000
I would like to use a perl compatible regex engine in the less command line utility. Is that possible?
Not out of the box. What you can do as a substitute is to send the input to grep --perl-regexp (or -P) before piping it to less, for example: some_command | grep -P … | less If you want to see the rest of the file as well, with the matches highlighted, you can use this trick and pipe the result to less --raw-control-...
Can I change the regex engine used to search in `less`?
1,375,280,881,000
I installed the beep tool (from normal rep) on my ubuntu 18.04 After modprobe pcspkr everything was OK. But it has been heard from my very small beeper from the PC's box only. Is there a way to hear it from normal music loud speaker as like any mp3, youtube etc? I note the echo -e '\007' bell command from my shell is ...
Welcome to Unix & Linux StackExchange! The beep tool is explicitly designed to use the beeper only. The echo -e '\007' uses whatever bell effect your terminal emulator is configured to do: on the text-mode console, it typically uses the beeper. In a GUI desktop terminal window, the terminal emulator might have its ow...
Is there a way to switch the output sound of the beep program to the normal loud speaker instead of beeper?
1,375,280,881,000
I am using this command chain to filter out bot/crawler traffic and ban the ip addresses. Is there any way i can make this command chain more efficient? sudo awk -F' - |\\"' '{print $1, $7}' access.log | grep -i -E 'bot|crawler' | grep -i -v -E 'google|yahoo|bing|msn|ask|aol|duckduckgo' | awk '{system("sudo ufw de...
Using a single awk command: awk -F' - |\"' 'tolower($7) ~ /bot|crawler/ && tolower($7) !~ /google|yahoo|bing|msn|ask|aol|duckduckgo/{system("sudo ufw deny from "$1" to any")}' access.log This will filter out only entries that have bot or crawler in the 7th column (what your first grep command does. Only if the 7th c...
any way to make this command chain shorter or better
1,375,280,881,000
I was restoring a backup of my Raspberry Pi on a new micro SD card. The original card was 16Gb and the destination card was 16Gb, too. However, during the transfer dd complained that there isn't any space left. Now, I know that every card has a different real size, but how can I fix that? Is it possible to "chop" off ...
Yes, you can "chop" bytes off a raw disk image file using truncate. truncate -s 15G image.raw Obviously, this will affect the data within the disk image. You probably want to shrink the contained filesystems so they are not truncated along the way. gparted is a tool with nice UI to achieve this. gparted image.raw Ju...
dd: No space left on device
1,375,280,881,000
in the context of automating the installation of a machine, I would like to configure firefox, specifically the proxy settings, from the command line, either by executing commands or by editing configuration files, for example. Is this possible, and if yes how? Edit: I forgot to mention that I would like to configure ...
You have basically two choices (that i can think of) Launch firefox, and update your profile with the correct settings (proxy ones for example). Then close and retrieve your configuration in ~myusername/.mozilla/firefox/xxxxxxx.default/prefs.js. xxxxx is a dynamic string. You can then use this user preferences for y...
Configure firefox without using the gui
1,375,280,881,000
Hello Unix & Linux Community, I am here to ask how I can translate a Windows Batch File (.bat), into a Linux Bash File (.sh), because I want to allow a program I made, into Linux. But I have no idea how to get it to work in Linux. I understand that some things, like EXEs, are "non-existent" in Linux. So, the code I wa...
I'm afraid there is no automated way to convert a BAT script into Bash. This leaves you with two options: Option 1. Convert the script manually. The script that you linked looks simple enough, which means it shouldn't take much time to convert it once you're familiar with the basics of Bash scripting. This book should...
Translate BATCH to Bash
1,375,280,881,000
Goal: Play music on a server, preferably using cmus, using SSH for player control. First try: cmus I run cmus in a terminal, literally nothing happens. It just loads (i guess). Tried cmus -vvvvv - Also just loads. Tried this and this - No changes to the issue. But: running it from a physical terminal on the computer w...
I solved the issue with something rather obvious I missed this whole time. I had to allow other users (not the user logged into the X session under which the pulseaudio deamon runs) access to PA. On the user under which the PA deamon runs: # create pulse config dir in $HOME if it doesn't exist yet mkdir .pulse # copy ...
Almost every CLI music player doesn't work (in an SSH terminal)
1,375,280,881,000
Why are files listed alphabetically, ignoring file name length in the terminal? Perhaps I shouldn't say "ignoring" file name length, but rather, why is there a difference in displaying files in the terminal vs. a GUI. This is certainly a trivial question, but I've been a bit curious about this one for a while. In the ...
The default ordering for ls is alphabetical. In this scenario, digits are not numbers just characters. So file1 is a shorter name than file10, but otherwise identical, and therefore comes before it in the list. If you want natural versioned order you could try ls -l --sort=version (or ls -lv) -rw-r--r--+ 1 roaima 0 Ma...
Why are files listed alphabetically, ignoring file name length in the terminal?
1,375,280,881,000
On my local box "machineA", I have two folders "/primary" and "/secondary". These two folders have some files in it. Now on the remote server "machineB" I have one folder "/bat/snap/" which contains lot of files. All the files in "/primary" and "/secondary" folders in "machineA" should be there in "machineB" remote s...
This is what the various md*sum files are written for. On machine A: find primary secondary -type f | xargs md5sum > checksum.md5 (copy file to machine B) Machine B: md5sum -c checksum.md5 Edit: Combined into a single command: find primary secondary -type f | xargs md5sum | ssh machineB '(cd /location_on_B/ && md5sum ...
compare checksum of files between two remote servers
1,375,280,881,000
I have the following script to monitor some running processes: $ cat ./print_running.sh #!/bin/bash ps aux | grep 'python energydata.py' | sed -r 's/\{"spectral": 0//;s/, "pp_enable.*y": 0.9,//;s/ "consumer.*ressure": 0.15,//; s/ "gamma.*//' When I run it from the terminal I get output like below: user 27994 37.6 ...
It looks like it has to do with ps truncating the output when in watch, see watch cuts off ps aux output when piped for a detailed explanation. The solution is to manually specify the column width for ps, and then it works even inside watch: #!/bin/bash COLUMNS=2000000 ps aux | grep 'python energydata.py' | sed -r 's...
Bash (sed) script works directly from command line but not through watch
1,375,280,881,000
I have an android app and has alot of Log.d(.....); type messages that I would simply like to remove. I just want a command that removes them all (should go through all directories recursively) One challenge however is that some Log.d commands go to the next line, and so some are like this: Log.d("I can be easily dele...
Basic script I've used perl because it's simpler to match over multiple lines (unlike, say, sed). The basic script is as follows. perl -0777 -pe 's/^Log\.d\(.*?(\n.*?)*?\);\n//gm' input Explanation perl -0777 -pe: invoke perl using -0777 to slurp the entire file, i.e. allowing multi-line processing. 's/foo/bar/gm': ...
Delete all lines that start with Log.d
1,509,615,539,000
we add the following user to the group white_house kuku , trump , karter usermod -a -G white_house kuku usermod -a -G white_house trump usermod -a -G white_house karter as all know we can verify that users was added to the group by grep white_house /etc/group but is it possible to verify it by some command line or ...
You could use getent getent group white_house or if you want to check a specific users groups you can use groups groups karter
how to verify users are in group
1,509,615,539,000
I would like to setup a paste functionality allowing to paste copied text (like scripts and configuration files) to any kind of application, including virtual guests and remote sessions running graphical clients such as VNC (where a standard copy-paste is not possible). To achieve this, I associated a shortcut in my d...
For historical reasons, there are two characters that represent line breaks: line feed (commonly represented as LF, \n, \012, Ctrl+J, …) and carriage return (CR, \r, \015, Ctrl+M). Unix uses LF as the line terminator character, but keyboards send CR when you press Return. Some applications recognize a Linefeed key (wh...
`xdotools type` mangles carriage returns
1,509,615,539,000
How can I find all groups of images which have the same exif timestamp in a given directory from the command line in linux?
Well, let's say you are using exiftool and a command like exiftool -sep $'\t' -T -filename -createdate dir This prints one line per image in directory dir with the filename and its creation timestamp. I don't know if this is the timestamp you had in mind but you can always change that field. Pipe output of that comma...
Find images with same exif timestamp
1,509,615,539,000
I have many separate lists from all of which lines containing "@" as the start are wanted. I am now using sh list_of_commands to process the files. I am wondering if there is a smarter method to do the job. 1) How could I batch process all the files without writing all the command lines one by one? 2) Any method that...
The following script crawls through all the files in the directory in which the script is executed and applies commands to it one by one. Is that the thing you want? #! /bin/sh for file in * do if [[ -f "$file" ]]; then # process the file with name in "$file" here fi done You can perform the renaming of ...
Batch processing many files [closed]
1,509,615,539,000
My teacher lists the following chaining operators: & && ( ) ; ;; | || new line How is ;; a chaining operator and what does it do?
Your teacher will probably talk later on about case statements in bash and how each option statement is closed by ;;. As in: case $space in [1-6]*) Message="All is quiet." ;; [7-8]*) Message="Start thinking about cleaning out some stuff. There's a partition that is $space % full." ;; 9[1-8]) Message="Better...
Is ';;' a chaining operator in Unix? How does it work? [duplicate]
1,509,615,539,000
I have a program, let is call it xcommand. when it is running, it has no stdout, but it writes its output to a file. What I want to a achieve is like this: After I running xcommand, during its running I want to see its output in real time, and if I found something abnormal, I then turn off the output and at the same ...
When non-interactive (like in scripts), shells don't do job control. They don't put asynchronous jobs in background. Those remain in the same process group as the rest of the script, so Ctrl-C will cause a SIGINT to be sent to them as well (assuming the script itself is started in foreground). You can issue a set -m f...
Is it possible to keep a command sequence running after sending ctrl+c in the intermediate step?
1,509,615,539,000
I need to show the total but I have only found the command to list the installed packages with this: ls -l /var/log/packages/
Using wc -l will print the total line count. Pipe your ls content into it using ls /var/log/packages | wc -l This will give you the total number of packages installed in /var/log/packages. The reason I left out -l in my command was because in most cases that will print the total block count at the top of the direct...
command to see the total installed packages in Slackware?
1,509,615,539,000
I'm running a raspberry pi 3.0 on rasbian jessie lite and using a flat mac keyboard with the number pad on the right side. I do not have a GUI interface. I went to change my keyboard layout because it was not correct (I couldn't use |). To do this, i installed console-common which let me select my layout from a list. ...
To reconfigure the keyboard in Debian, run (as root, or using sudo): dpkg-reconfigure keyboard-configuration Link to official Debian documentation here. If your keys are "random" (I have been there, not fun!), try to find the characters needed to execute the command above.
Revert setting the keyboard layout
1,509,615,539,000
One way to find the names is to look at /home/ and see whichever entries are on the system. To look at current users one can use #users to see how many users are there. If a single user has spawned many sessions you will get something like - root@debian:~# users shirish shirish shirish shirish shirish shirish shi...
There are several ways. last, who and ps are all relevant here. last is the most thorough for tracking current and past logins. From the man page for last (emphasis added): Last will list the sessions of specified users, ttys, and hosts, in reverse time order. Each line of output contains the user name, the...
How to find out names and numbers of users on your system?
1,509,615,539,000
Recently, I dumped my memory strings (just because I could) using sudo cat /dev/mem | strings. Upon reviewing this dump, I noticed some very interesting things: .symtab .strtab .shstrtab .note.gnu.build-id .rela.text .rela.init.text .rela.text.unlikely .rela.exit.text .rela__ksymtab .rela__ksymtab_gpl .rela__kcrctab ...
These look very much like section names from the Linux kernel. The ones prefixed by .rela contain relocation information for the named section, e.g. .rela.text is the relocation information for the text section (where kernel object code is stored). Other sections of interest are: .modinfo - kernel module information...
What are these memory strings? What do they do? [duplicate]
1,509,615,539,000
Actually I am using sed -e s/Perro-A//g -i *-a.log to delete the string Perro-A from many files ending with *-a.log. But sometimes in the files I might not have Perro-A; I might have strings like Perro-B, Perro-C, Perro-14, Perro-X , Perro-DHFN, etc. I need to update the previous command to delete any string starti...
Assuming you just wanted to delete all string starting with "Perro", you can use: sed 's/Perro[^ ]*//g' *-a.log If you want to edit the file in place, you can use -i option with sed, like sed -i sed 's/Perro[^ ]*//g' *-a.log Update If you don't want to have multiple spaces, you can use: sed -i sed 's/Perro[^ ]*//g' ...
How to delete a variable string in file
1,509,615,539,000
I am currently having a hard time understanding the following find command: find / -o -group `id -g` -perm \  -g=w -perm -u=s -o -perm -o=w\ -perm -u=s -o -perm -o=w \ -perm -g=s -ls  Specifically this portion: find / -o -group `id -g` -perm -g=w -perm -u=s I understand that -o works just like an or operator. If...
From the find(1) manpage: The -H, -L and -P options control the treatment of symbolic links. Command-line arguments following these are taken to be names of files or directories to be examined, up to the first argument that begins with -, or the argument ( or !. That argument and any ...
Understanding the following find command
1,509,615,539,000
I would like to know how to find all files in the /etc file beginning with P, which I will then store the results of in a new file. So far I have $find /etc -name Unsure of what comes next.
If you want to find all regular files beginning with P, you can use: find /etc -type f -name 'P*' If you want to no recurse into subdirectories: find /etc -maxdepth 1 -type f -name 'P*'
How to find all files in /etc beginning with P
1,509,615,539,000
I am working on a project in which the user can upload videos. Is there any way with FFmpeg I can take some images from the video and create a GIF out of it? As the project is in Java, I have a way to get an image from a video, but to create a GIF requires multiple images, and it's proving costly. The server is runni...
I do scene extracting from videos using vlc for linux. If you don't have it, use apt-get install vlc to install it. Once installed, you can use a variance of the following command line to extract frame(s) out of your video. The default image format is png and it is good for my purpose. If you insist on gif images, I ...
FFMpeg : Converting a video file to a gif with multiple images from video
1,509,615,539,000
I'm new to Linux. I wonder if it is possible to make terminal display directory contents automatically while I typing a command with directory arguments? For example, if I want to do cp ./fileA ~/folderA/folderB/folderC/fileA Sometimes I can't memorise the destination directory correctly, as a result I need to use ls...
The usual action in case you don't remember the name is to press Tab. Most shells (including bash, zsh, ksh) will guess as many characters as they could on the first keystroke, then display a list of matching files and directories on the second. For example, if you have dir1, dir2 and dir3 in your home directory, then...
Is it possible to display directory contents automatically while typing command?
1,509,615,539,000
Currently my computer is not allowing me to start it up properly (guessing my hard drive is malfunctional), but I've figured out that Ctrl+Alt+(F1,F2,F3,F4,F5,F6,OR F7) allows me to access command-line. So I was hoping that being able to do that would allow me to get all the necessary information from a specific file....
Depending on the user you are using, you may need to type su - or sudo first to get root privileges. Type lsblk: > lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 111,8G 0 disk ├─sda1 8:1 0 1020K 0 part ├─sda2 8:2 0 41G 0 part ├─sda3 8:3 0 11G 0 part ├─sda4 8:4 0 ...
How do I transfer (to a usb drive) or read a .odt file in the command-line?
1,509,615,539,000
I am trying to build a one-line command to monitor when my Internet connectivity drops. I'd like it so that if I run ping www.google.com indefinitely (one ping per second), if the word "timeout" exists in an output line, another command runs, but the ping command continues to run indefinitely. I'm running this on OS...
Your problem comes from the ping command that never exits. You should make a loop that call ping for one test -c 1: while [ true ] ; do if ping -c 1 www.google.com | grep timeout ; then say fail ; fi ; sleep 1 ; done edit I wrote a bash while loop, may be you should adapt it to your shell program (It's been a long t...
Execute a command after each output line from ping command
1,509,615,539,000
I am running this command: ssh -i key user@domainname 'bash -l -c "command"' The command script calls on another script that asks for input at some point. The problem is that the prompt for the command asking for input comes after I type in the answer to the prompt, which obviously is bad because I don't know what I a...
Try allocating a terminal on the ssh host: ssh -t -i key user@domainname 'bash -l -c "command"'
Showing prompt from ssh command
1,509,615,539,000
I have been looking for lesser known commands that reads their standard input in special cases(missing arguments , for example). I'm thinking "cat" or maybe other command would fit here.
There are a few cases that come to mind: missing arguments, the special argument "-", the program detects that the standard input is not a terminal, and an option (or environment variable) overrides the behavior. For missing arguments, cat is a useful example. Likewise grep, sed. The special argument "-" is used in...
Is there any command that read their standard input in special cases? [closed]
1,509,615,539,000
When I run grep -m 1 -Fnxvf file1 file2, for some couple of files I get a different line number than running grep -m 1 -Fnxvf file2 file1 (swapped files). Why? I've reduced the files to a minimal example. file1 Pp: 1 Id pezzo 193 posIn = { x = 132, y = 1432 } Pp: 1 Id pezzo 193 posIn = { x...
TLDR: you have no guarantee grep will use your pattern in order. Suppose you have two files with following contents (one letter per line, I fold for readability) File 1 A B D E and File 2 A B C D The first excluded (since you use -v ) letter from set 2 (A B C D ) in file 1 is E. The first excluded letter from...
Why grep shows different results when I use file1 as a pattern on file2 and viceversa?
1,509,615,539,000
I need to figure it out how many times a particular string shows up in column 4. This is my data: 25 48656721 48656734 FAM132B ENSCAFT00000019683 4 0.51 X 53969937 53969950 FAM155B ENSCAFT00000026508 5 0.57 3 42203721 42203906 FAM169B ENSCAFT00000017307 5 0.54 36 28947780 28947831 FAM171B ENSCAFT00000046981 5 0.51 ...
One simplistic solution would be to use awk to pull column 4; uniq -c to count them; and another sort to put them in order by the second column (the old column 4 data): awk '{print $4}' < data | uniq -c | sort -k2 On your (updated) sample input, this gives: 1 FAM132B 1 FAM155B 1 FAM169B 2 FAM171B 3 FAM193A ...
Listed Frequency of Different Strings in a Particular Column
1,509,615,539,000
I'm designing a terminal-based application, and I want to implement a --silent flag to suppress noise if they don't want it. In this application, errors are most commonly logged when the application cannot perform a necessary task, warnings are logged when something couldn't be performed, but the application can still...
As you see with curl / ruby, there is no genereal convention. It greatly depends on your application and what can go wrong with it. It also depends on how it is used. For some application it makes sense to have --quiet and --really-quiet flags, for some it's just overkill. Also a --really-quiet flag is usually not req...
Is a "--silent" flag supposed to suppress warnings and errors, or just warnings?
1,509,615,539,000
On Mate systems, many programs correspond to (and are sometimes forks of) other programs with more well-known names: nautilus -> caja gnome-terminal -> mate-terminal ark -> engrampa gedit -> pluma Sometimes I get lucky and just replace gnome with mate. Sometimes I have to resort to opening a file through a GUI and ...
I'm afraid not. Most Linux distributions provide some set of basic utility programs - graphical text editor, image viewer, file manager, window manager, terminal emulator, and so on. While some of these programs' names could be possible to get rather easily, if you are checking this on somebody's system and not a fres...
How to find what the "Mate version" of programs are called
1,509,615,539,000
I executed a command like this: nohup some_command &. Now this command is in the background. I can see it with the command jobs. Example output: [1]+ Running nohup some_command & Is it somehow possible to have a live representation of the status that comes from the jobs command, similar to how top wo...
If all you want is for job completion notifications to be printed immediately, even if you're at typing a prompt or if some other job is in the foreground, then just run set -o notify. If you want a foreground command that displays the status of background jobs from the current shell, you can run jobs in a loop. It's ...
Live monitoring of background jobs
1,509,615,539,000
For these commands (in both bash and fish): sudo emerge eix emerge eix I get this error: usage: emerge [-h] [--version] [input [input ...]] emerge: error: argument input: can't open 'eix': [Errno 2] No such file or directory: 'eix' Same thing with livestreamer (and "pip install"): #~/temp> livestreamer http://www.tw...
The programs you're having trouble with are all run using the dev-lang/python-exec script wrapper, which appears to have been somehow corrupt. To attempt to re-install that package, assuming nothing else was severely harmed, you can try (adjust the version number to match your installed packages): /usr/bin/python2.7 /...
Python now thinks arguments are files: Broken emerge, pip, livestreamer and most tools using Python
1,509,615,539,000
I'd like to rip the titles from a bunch of word documents. All the CLI tools I've tried for converting .doc to text lose the title... but Abiword's conversion to RTF preserves it, eg: $ abiword --to=rtf something.doc gives something.rtf, a text-encoded file that includes the title. So far so good but I need one line ...
There's an example in the abiword man page: abiword --to=rtf --to-name=fd://1 something.doc
How to redirect output from file to stdout?
1,509,615,539,000
I am reading up on several commands, some of which are privileged and some that may or may not be installed. My system (gentoo) will respond with command not found sometimes when the program in the system. How do I match the behavior of something like emerge? Example of behavior I would like: $ emerge -av mypackage ...
The directory containing lspci is likely not in your PATH. You can find its location using sudo -i which lspci and add the directory to your path. The likely locations are /sbin or /usr/sbin To add them you your current PATH, you can run (in a Bourne-based shell) export PATH="$PATH:/usr/sbin:/sbin" To make the change ...
How do I allow privileged commands to fail but respond?
1,509,615,539,000
I currently have 2 bash command line strings I use to gather data needed for a certain task. I was trying to simplify and have only one command used to gather the data without using a script. First I cat a file and pipe into a grep command and only display the integer value. I then copy and paste that value into an eq...
Here it is as one command: echo $(( (2147483633 - $(grep -i isrs /proc/zem0 | grep -Eo '[0-9]+$') )/5184000 )) How the simplification was done First consider this pipeline: cat /proc/zem0 |grep -i isrs` This can be simplified to: grep -i isrs /proc/zem0 Thus, the whole of the first command becomes: grep -i isrs /pr...
Using the output of `grep` as variable in second command
1,509,615,539,000
I stumbled across a useful command line recorder that allows the user to copy the text when watching the 'recording'. I just cannot remember the name of the project. I just remember you can play and pause the video and the user can copy and paste the text in the video. Anyone know the name of the project?
Might it be asciinema, showterm or PLAYTERM/ttyrec? Coincidentally a colleague of mine is right now trying to remember something like this as well.
Cannot remember the name of a CLI recorder software
1,509,615,539,000
I am using OSX 10.9.5 Whenever I open a terminal, it says something like: Last login: Wed Jan 21 10:29:13 on ttys002 You have mail. What mail is it talking about ? If I open the mail app, I have no new mail. This is a laptop, and I have not setup a mail server, so how do I find out why it is reporting I have mail ? A...
Well, you probably have mail. ;) It talks about your local inbox. Use mail or mutt or from to see your local mails. I'm not sure what mail client is installed per default on OSX, but I would expect to find mail on pretty much any unix system. OSX, at the end, is just another unix and unix is designed to be a multi-use...
Why does terminal say I have mail every time I open it?
1,421,059,115,000
I have recently installed sdcv(console version of Stardict offline dictionary) and have installed 5-6 dictionary files as shown here Whenever i search any word, using sdcv hello or sdcv cat , it gives the meaning of the word from all the dictionary files, on the console which clutters up the screen. How can I search ...
Use -u option: -u --use-dict filename for search use only dictionary with this bookname To search for a keyword in a specific dictionary create several aliases, for example def for general English, defl for Linux etc. Like this: $ alias def="sdcv -u WordNet" $ alias defl="sdcv -u 'GNU/Linux English-English...
Searching a word from a specific dictionary file in sdcv(console version of Stardict offline dictionary)
1,421,059,115,000
Consider a file with key=value pairs, and each key is optionally a concatenation of multiple keys. In other words, many keys can map to one value. The reason behind this is that each key is a relatively short word compared to the length of the value, hence the data is being 'compressed' into lesser lines. Illustration...
You can write it in much more readable form using awk: getval() { awk -F'=' '$1~/\<'"$1"'\>/{print $2}' testfile }
Extracting values from a file keyed by multiple keys
1,421,059,115,000
When I execute echo `man ls` > tem.txt I get unformatted output in the text file, I mean output without any new lines, just continues sentences. How do I get formatted output ? For example, unformatted output looks like: LS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... D...
You don't need to force man's output via process substitution. Redirection works fine for it: man ls > tem.txt Even if you so use process substitution, remember to use quotes, otherwise the output will undergo splitting + globbing from the shell: echo "$(man ls)" > tem.txt
how to `echo` 'formatted' man page of some command to text file [duplicate]
1,421,059,115,000
I have a script, run.sh, that looks like this: #!/bin/bash FILES=$(find corpus/ -type f) for i in $FILES do ./individual.sh $i done It runs without problem. I want to do away with the run script by piping each file from find to ./individual. I would think that I could just do: find corpus/ -type f | ./individual....
You'll want to use find's -exec option: find corpus/ -type f -exec ./individual.sh {} \; For each match that find finds, it'll execute individual.sh, replacing {} with the name of the file it found. \; is how you end an exec with find. The reason your pipe doesn't work is that the output from find is being provided t...
Confused about piping commands from find to commandX?
1,421,059,115,000
I am using cpufreq to scale my CPU frequency. But I do that by clicking cpufreq icon on the panel of Ubuntu 12.04. If without a mouse, how can I show and scale CPU frequency by running commands in terminal?
cpufreq-info - Utility to retrieve cpufreq kernel information. It will list available frequency steps, available governors, current policy etc. cpufreq-set - A tool which allows to modify cpufreq settings (try e.g. cpufreq-set -g performance or cpufreq-set -f 2 GHz once you know what frequencies your CPU can be set t...
Scale cpu frequency in CLI?
1,421,059,115,000
How to display contents of mounted /boot and '/' root partitions of Debian on SSD drive from Linux Live CD? I know ls -1 to list directory contents, but what is exact steps to get this?
Mounting a HDD To mount a HDD that's physically connected to your system, you first need to identify the device handle that's been assigned to it. I typically use the command line tools blkid or lsblk to find out this information. blkid $ sudo blkid /dev/sda1: UUID="XXXXXX" TYPE="ext4" /dev/sda2: UUID="XXXXXX" TYPE="...
How to display contents of mounted /boot and '/' root partitions?
1,421,059,115,000
When I list processes with ps auxf I often see some that are stuck and I need to manually kill them. How can I do it with one command? Example ps result: $ ps auxf USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND tommass 7971 62.3 1.1 316428 45844 ? R Aug08 29133:14 xxxxxxxx t...
to answer 1), start with ps -u tomass -o pid,time (depending on you context, you may wish to select time (cpu time), etime (elapsed time)) to answer 2), try ps -u tomass -o state,pid | awk '$1 == "R" { printf "kill %d\n",$2 ;}' | ksh You really want to kill Running process ?
How to kill all processes for a given user that take longer then X time
1,421,059,115,000
I am interested to know if a single command line that would allow me to recursively copy a folder to all of our NGINX Virtual Host htdocs folders: I need to copy that folder to all hosts located in vhosts : /var/www/vhosts/*/htdocs/
With all due respect, I don't think the above code/answer is correct. if [ -d dir] is probably an attempt to if [[ -d "$dir" ]].. or [[ -d "$dir" ]];.. The following code should work and do what you want. vhostdirs=( ./var/www/vhosts/* ) for dir in "$vhostdirs" do cp -r "folder_to_be_copied" "$dir/htdoc...
Copy a folder and its content to all Nginx vhosts host
1,421,059,115,000
How do I install software using yum? Can you tell me another way to install package in Fedora?
sudo yum install foo will look for foo in the package repositories and install it if it exists. Sometimes the name of packages is not obvious, so you may want to use yum search foo to see if there are any packages available pertaining to "foo". man yum will give you some details about the packaging program.
How to install package via yum in Fedora
1,421,059,115,000
What I'm trying to do I'm using a Logitech MX Revolution mouse, which has a button below the scroll wheel mapped to search, which I remapped to middle click. For doing so, I had to remap XF86Search to middle click using xbindkeys, which works fine – when I change the "Search" hotkey to something else, for example Ctrl...
I found this AskUbuntu Q&A titled: Bind a mouse button to show the Gnome Shell Activities overview. The OP from that Q&A posted that this solution worked for him/her using xbindkeys: "xte 'keydown Alt_L' 'key F1' 'keyup Alt_L'" release + b:10 There were other suggestions in that Q&A as well, so if the accepted an...
How to invoke Gnome 3 activity screen via mouse button?
1,421,059,115,000
I need to replace all unwanted spaces in all files from the current directory and from directories from the current directory (recursive search). I define the unwanted spaces the spaces and tabs that are at the end of the line and are not followed by any other character than \n (the new line character). e.g.: This is ...
Something like the following should suit your needs: find -type f -exec sed -i 's/[[:blank:]]\+$//' {} \; Note that sed's -i option is not safe with symlinks -- it will break them. If this is a problem, consider using ed or ex.
Replace spaces and tabs at the end of the line in all files
1,421,059,115,000
What does ; mean in single line scripts like this: while true; do sudo -n true; sleep 60; kill -0 '$$' || exit; done 2>/dev/null & Does it mean new line, or "next command"?
It's a separator of commands. Though in the first instance, it might be better to think of it as ending the while statement. For example, if you wanted to do a loop while some command returns success, you would do something like while test -f /foo; do some_command; done` The semicolon is used to indicate the end of t...
What is the use of ; in a single line command?
1,421,059,115,000
Is there a command that can tell me which my graphic card is and its pixel-depth? I am running vncserver and I would like to learn which is the best parameter for pixeldepth (-depth).
xdpyinfo gives you this information. A display can support multiple depths. xdpyinfo | awk '$1=="depth" && sub(/,$/, "", $2) {print $2}' If your display consists of multiple screens, they may support multiple depths. xdpyinfo | awk ' $1=="screen" {screen = substr($2, 2, length($2)-2)} $1=="depths" {$1=$2=""; ...
How do I find out the pixel depth of my graphic card?
1,421,059,115,000
Is there a command where, when entered outputs information such as: If the network connection is wired or wireless if it is a wireless network, the name of the wireless network How strong the signal is
Just type in terminal 'iw' and then press Tab and you will see something like iw iw iwconfig iwevent iwgetid iwlist iwpriv iwspy all those are related to wireless internet, try iwconfig to show statistic about signal and network interface.
Get network information through Ubuntu Terminal
1,421,059,115,000
I have many HTML files containing mixed unicode strings like \303\243 and printable characters like %s. What I'd like to do is converting the unicode strings into printable characters in a safe way. I found that printf from GNU coreutils converts them automatically, but I also learned the hard way some time ago that p...
If the files don't have other backslashes: $ printf %b\\n 'aa\303\243' aaã If they do, you could double backslashes that aren't followed by integers: $ printf %b\\n "$(sed -E 's/\\/\\\\/g;s/\\(\\[0-7])/\1/g' <<< '\\a\na\303\243')" \\a\naã
Safely convert unicode strings to printable characters
1,421,059,115,000
I have this command $ cut -f2,3 AIS2F1 | grep [2-9][0-9]* | cut -f1 So my second and third fields are something like this Ben 434 Me 12 you 56 So, I thought that the logic should be to cut the second and third field then grep numbers that are bigger than 20 and then cut the first field. That should give me the n...
The * in grep means that zero or one of the previous occurrences will be matches. Thus, your grep command matches every line containing a [2-9]. Replace the * with a \+, which means: match one or more occurrence.
Grepping number in a file
1,421,059,115,000
I am looking for a tool which takes a file in input and a word to search. It should display the file with color the words if it corresponds to the search. Like grep --colors but displays all the file. Is there something already exists ? Example : cat /etc/passwd | colors root Display all /etc/passwd file and color the...
A little trick with grep will do the job: grep --color "^\|root" /etc/passwd Otherwise look here.
Display words in color
1,421,059,115,000
How can I run the most recent command again from history in AIX Server? And how to edit the most recent command and run it again in AIX?
what shell are you using? if korn? 'r' will run the previous bash? ctrl-p or up-arrow or '!!' to edit the command try using fc - it will used the $EDITOR env variable and open up the editor. For example if it's vi then it'll open vi with the command and when you save exit (ZZ or wq) it'll run it.
How to run the most recent command on AIX?
1,421,059,115,000
There is a Linux program I like which is Conky, when I run conky -c mycustomconf.txt it runs fine. I want this program to run automatically when I start my computer, without having to type in the command again to start it. How can I do this? I am using Ubuntu with Xfce4.
You can add programs that you wish to start up alongside Xfce to your startup items using xfce4-autostart-editor, which is accessible at Settings, and then "Xfce 4 Autostarted Applications".
Running a program automatically?
1,421,059,115,000
I'm trying to set up my Arch Linux so that, through non-graphical means, I can connect to a wireless network through profiles on my system. I have tried net-auto-wireless, and it does everything I have specified, but I want it to be able to connect once it has the ability. For instance, if the first attempt was unsucc...
There is a helpful comparison of wireless management methods on the Arch Wiki. If you are looking for a combination of automation, ie., you do not want to manually issue commands every time you connect to a network, and are looking for a lightweight solution that can be run both in X and in a TTY, then wicd-curses ful...
How to Connect to Wireless Automatically? (Non-graphical)
1,421,059,115,000
Lets say in file.php, there is lots of php print text: <?php print t('Blabla'); ?>, <?php print t('Text Here'); ?>, etc. What I need is to remove <?php print t(' and '); ?> of the php print text. So, <?php print t('Blabla'); ?> will become Blabla, <?php print t('Text Here'); ?> will become Text Here, etc. If one php p...
I suppose your intention is to remove an old internationalization system from your PHP scripts. perl -e 'undef$/;$s=<>;$s=~s/<\?php\s+(?:print|echo)\s+t\((['"'"'"])(.*?)\1\);\s+\?>/$2/gs;print$s' apasajja This has some improvements not asked in the question: Works for both print or echo. Works for both single and do...
Replace "<?php print t('Blabla'); ?>" to be "Blabla"
1,421,059,115,000
I have an XML file and I would like to replace everything that is between the open and closing tag within multiple instances of the g:gtin node with nothing. Is this possible from the command line, using sed or something similar? <g:gtin>31806831001</g:gtin>
A simple solution for simple cases - see my comment: echo "<g:gtin>31806831001</g:gtin>" | sed 's|<g:gtin>.*</g:gtin>|<g:gtin></g:gtin>|' Result: <g:gtin></g:gtin> It depends on the assumption that start and endtag are on the same line, and not more than one tag is on that line. Since xml files are often generated ...
regex replace text in xml file within node from the command line
1,421,059,115,000
I'm using a wonderful program called ExifTool to recursively rename a large batch of files. Here is example usage: $ exiftool -r -ext JPG '-FileName<CreateDate' -d %Y%m%d_%H%M%S.jpg . Error: './folder1/110310_135433.jpg' already exists - ./folder1/source.jpg Warning: No writable tags found - ./folder2/110404_095111.jp...
This will extract the filenames from the errors/warnings of exiftool and create a replica directory tree under the folder `unprocessed' with only those files. Didn't try to just move them in a single directory to avoid the risk of overwriting files with the same name but different source dirs. exiftool ... 2>&1 | tee ...
Simultaneously move long list files to new location
1,421,059,115,000
I've been trying to find a decent way to monitor elapsed time in the shell. Basically, I'm asking for a stopwatch. The end result is easy enough to accomplish; I've seen examples of using time read, and then hitting enter when you're done, but that method makes the current terminal unusable. Ideally, I'd like somethin...
You may try a shell script (call it timer.sh) like this: . timer.val case "$1" in start) echo $TIMERSTART echo "TIMERSTART=`date +%s`" > timer.val echo $TIMERSTART ;; stop) echo $TIMERSTART TIMEREND=`date +%s` echo $TIMEREND let RESULT=$TIMEREND-$TIMERSTART echo $RESULT ;; *) e...
Command to monitor elapsed time in background?
1,421,059,115,000
I was wanting to know how to remove newline characters in paragraphs in this book and others for use in a kindle. The desired effect is to have each block that is separated by a blank line to be turned into continuous lines of text. I got the job done for this book with a series of complicated vim substitute commands ...
If the paragraphs already separated by two or more newlines and you only want to remove the newlines inside each paragraph (or better yet, replace newlines with a space), then: perl -00 -lpe 's/\n/ /g' pg42324.txt > pg42324-new.txt -00 tells perl to read & process the input one paragraph at a time (a paragraph bound...
How to remove newline characters inside paragraphs with sed or awk
1,421,059,115,000
What flags do I need to add to $ curl -o a URI1 -o b URI2 -o c URI3 to make it say Getting URI1 Getting URI2 Getting URI3 sort of like wget? No I don't want to need to pipe the output of --verbose etc. through grep, awk, perl, etc. (Yes, --silent gets rid of the timing info. That gets us a little closer to our desir...
The closest you'll get with only curl seems to be the -w flag: -w, --write-out Use output FORMAT after completion $ curl --silent --show-error -w "Download of %{url} finished" -o a URI1 -o b URI2 -o c URI3 To see all of the output control options you can do: curl --help verbose
How to have curl print the URL that it is fetching?
1,421,059,115,000
I want to print the lines of updates via this command dnf check-update --refresh --q --downloadonly | wc -l However during the output there occurs a blank line which means the true update number is will be less than 1 from the output of the above command. How can I subtract 1 from the above command, in a one line comm...
Just change wc -l by grep -c . to skip the blank line: dnf check-update --refresh --q --downloadonly | grep -c . or dnf check-update --refresh --q --downloadonly | sed '/^$/d' | wc -l or if you insist to do arithmetic: printf '%s\n' $(( $(dnf check-update --refresh --q --downloadonly | wc -l) -1)) $((...)) is an ar...
Arithmetic operation in terminal from an output
1,421,059,115,000
On Linux I can do: echo ${ANDROID_KEYSTORE} | base64 -di > android/keystores/staging.keystore But on macOS, the same commands give: base64: option requires an argument -- i Usage: base64 [-hvDd] [-b num] [-i in_file] [-o out_file] -h, --help display this message -Dd, --decode decodes input -b, --break ...
If you want portability, you'll have to implement the linux-flavour's -i yourself # don't forget to quote the variable! echo "${ANDROID_KEYSTORE}" \ | sed 's/[^A-Za-z0-9+/=]//g' \ | base64 -d The sed command drops invalid characters
How to decode base64 for both Linux and macOS?
1,421,059,115,000
I'm using syncthing cli command to update settings in its config.xml file. I have found that it is working only for some parameters, eg gui.user and gui.password: $ syncthing cli --gui-address=localhost:8384 --gui-apikey=<KEY> config gui user set <VALUE> $ syncthing cli --gui-address=localhost:8384 --gui-apikey=<KEY> ...
If you run syncthing like so: syncthing cli config options ... then it will spit out a rather helpful text explaining how to use the cli config options sub-command. In the text, you will see all the available options, one of these being min-home-disk-free. Note the spelling. You may then drill further down to discov...
Using Syncthing cli to update its config.xml
1,421,059,115,000
I'm using gfind running on MacOS, to find text files. I am trying to see the filenames only and the birthdate of my gfind results, and then sorting them by date, and paging them. Is this achievable? For the moment I am trying gfind . -name "*.txt" -printf "%f \t\t %Bc\n" But the results are the following: todo.txt ...
Here, you can use: gfind . -name '*.txt' -printf '%-40f %Bc\n' or gfind . -name '*.txt' -printf '%40f %Bc\n' To print the file name left-aligned or right-aligned padded with spaces to a length of 40 bytes (not characters, nor columns unfortunately). That would align them as long as file names don't contain control, ...
Properly tabulating 'find's output with printf and sorting them by date
1,421,059,115,000
I have around 200 folders, each with 1000 or more jpegs inside, that all need zero padding to 4 digits. Some of these folders have further subdirectories containing deeper images. The photos are all named differently (ie in one folder they may be called Image_1.jpg, Image_11.jpg, etc, while another photo may contain f...
Use perl rename: rename -n --filename 's/\d+/sprintf("%04d",$&)/e' *.jpg or recursive: find . -type f -name "*.jpg" -exec rename -n --filename 's/\d+/sprintf("%04d",$&)/e' {} + the --filename flag makes sure to rename the filename only, not the path, otherwise you will end up with subfolder0001, etc. Remove the -n...
How to zero pad multiple files in multiple subdirectories using command line on linux?
1,421,059,115,000
Example: cat < test.txt Is the content of the file test.txt written/passed to stdin of the cat, and then the cat reads its stdin? OR Does the file test.txt itself become the stdin of the cat? In other words, is the stdin of the cat changed to test.txt by setting the file descriptor (fd) of the text file to 0?
Option number 2: test.txt is opened, and cat is set up with its standard input pointing to that file (the file descriptor is duplicated so that it’s 0 in the process which ends up running cat). On Linux, you can see this by running $ touch /tmp/foo $ sleep 120 < /tmp/foo & [1] 3006118 $ ls -l /proc/3006118/fd total 0 ...
How does Input/Output Redirection work in Linux/Unix?
1,421,059,115,000
Let's say I have a file listing the path of multiple files like the following: /home/user/file1.txt /home/user/file2.txt /home/user/file3.txt /home/user/file4.txt /home/user/file5.txt /home/user/file6.txt /home/user/file7.txt Let's also say that I want to copy those files in parallel 3 by 3. I know that with the comm...
If you use GNU Parallel you can do one of these: parallel cp {} destination/folder/ :::: filelist parallel -a filelist cp {} destination/folder/ cat filelist | parallel cp {} destination/folder/ Consider spending 20 minutes on reading chapter 1+2 of the GNU Parallel 2018 book (print: http://www.lulu.com/shop/ole-tang...
How can I use the parallel command while getting parameters dynamically from a file?
1,421,059,115,000
I have files like these : - REPORT_100_COMPLETED.csv - REPORT_100_FAILED.csv - REPORT_101_COMPLETED.csv - REPORT_101_FAILED.csv - REPORT_102_COMPLETED.csv - REPORT_102_FAILED.csv I want all of them to be put inside subfolder according to the related id : 100 | REPORT_100_COMPLETED.csv | REPORT_100_FAILED.csv 101 ...
for i in REPORT_*_*.csv ;do dir=$(cut -d'_' -f2 <<<$i) mkdir -p $dir && mv $i $dir/ done
How can I move all files matching a pattern into a new folder?
1,421,059,115,000
For example, to install a package with pacman one would use: pacman -S <package> While somebody using dnf would type: dnf install <package> While pacman uses the -S option, dnf uses the subcommand install. Some other examples are nmcli and tar, with nmcli connection up <connection> (uses subcommands) and tar -xzvf <f...
A more technical term for what you call a "word" is "subcommand". It is quite common to design a command line interface as a command with a number of subcommands each with its own set of options. Sometimes subcommands have their own subcommands. git is one such example: git remote add -f -t "$BRANCH_NAME" "$REMOTE_NAM...
When desiginng a CLI is there a preference/rule of thumb for using an option or a subcommand? [closed]