date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,533,849,977,000
I want to extract text infos from layer ( like font, font-style, font-size and content ) with the name and number of layer. All available command line on standard repo are an option. I know it can be done from Photoshop scripting, but for the sake of science I would like to do it from a Unix server, and maybe later ...
GIMP has the script-fu scheme extension that can be run from the command line. This will be sketchy because I have not written any scheme in some 3-4 years, but here goes nothing: Assuming the following script in a file called sc.sch: (define (go-by-layers no layers) (while (< 0 no) (let* ((layer (vector-ref la...
Extract text layer from PSD ( ImageMagick or GiMP )
1,533,849,977,000
I have a directory that goes like this: drwxrwxrwx 6 www-data www-data 4096 Jun 8 10:21 ./ drwxr-xr-x 31 user1 user1 4096 Jun 8 10:40 ../ lrwxrwxrwx 1 www-data www-data 66 Jun 8 10:21 archive -> /media/user1/7f62b5e4-4fe7-43c2-b0d0-8dad6e5a2381/archive/ I try to create a file with...
I fixed the probleme by mounting the hard disk pointed by the symbolic link. In fact, media/ is the path set by default so you need to mount the disk to set a valid path. Here is a link were you can find how to automatically mount a hard disk : InstallingANewHardDrive
Can't create a file through symbolic link
1,533,849,977,000
All programs/commands I attempt to print certain PDFs with (lpr, lp, Okular, Evince, Xpdf) print solid black pages. The one exception is Gimp, which allows me to import PDFs one page at a time and properly print. Obviously, this isn't a practical solution for multiple PDFs, so I would like to see exactly what command...
Running pdfinfo on the PDF generated by GIMP's print function, as well as checking the PDF file generated by GIMPs's post script function suggests that the program doing the print is Cairo. Here is the line in the Postscript file: Creator: cairo 1.14.8 (http://cairographics.org)
What command is gimp using to print?
1,533,849,977,000
How can I strip the time from a ping return? For example: 64 bytes from 10.3.0.1: icmp_seq=0 ttl=63 time=2.610 ms I want to grab the value after time= and pass it to a test like: if time>=50.0; then do_something; fi
So if you wanted to get just the time value without the ms label: HOST="127.0.0.1" PING_MS=`ping -c1 "$HOST" | /usr/bin/awk 'BEGIN { FS="=" } /time=/{gsub(/ ms/, ""); print $NF; exit}'` This gives me: 0.058 Now, if we wanted to test if time>=50.0, we could use awk for this, too, since POSIX sh itself can't compare ...
Comparing ping times in FreeBSD sh
1,533,849,977,000
I want to add this command into a launcher on the panel or desktop so that I can start the inserted DVD with a single click. I would prefer this to selecting one of the many options my KDE panel notifier offers, or to opening VLC, going to Media - Open disc etc. (On the other hand I prefer not to enable the option of ...
GAD3R gave the answer in a comment to the question: vlc dvd://
CLI command to start playing inserted DVD in VLC?
1,533,849,977,000
I'm trying to export the result of a command line as en environment variable. Here is how I'm doing it: group_id=$(aws ec2 describe-security-groups --filters Name=group-name,Values=${group_name} \ | jq '.["SecurityGroups"][0].GroupId' \ | sed -e 's/^"//' -e 's/"$//' ) However when I run the bash file, I get the ...
There seems to be a space after the backslash. To make multiline commands, the backslash must be the very last character on a line. Deduced from the output of set -xv: ++ aws ec2 describe-security-groups --filters Name=group-name,Values=docker-networking ' ' ...
Error when exporting the result of a valid command as a bash variable
1,533,849,977,000
I have a problem I have been trying to figure out: We have a stock file CSV, which contains the stock in multiple locations. The csv looks like this: stock_no,primary,secondary,tertiary,cstock,direct ABU0029843,1,,,5, ABU0029934,60,,,5, ABU0030034,,30,,5, I would like the end result to look something like this (essen...
You can try following awk: awk 'BEGIN { FS = OFS = ","; } NR == 1 { print $1, $2; next; } { for (x = 3; x <= NF; x++) $2 += $x; print $1, $2 } ' file
Adding two columns together in CSV and outputting to new CSV file
1,533,849,977,000
I have done a listing of the device folder two times, one time without the sd-card in the slot and one time inserted, the system automatically adds one file in the device folder. $ ls /dev | wc -l 205 $ ls /dev | wc -l 206 I could put each listing into a separate file: ls /dev > foo. But how can I determine from th...
You could run this before adding the device to store the inital list in a file: ls /dev >~/a And then this after adding the device: ls /dev | diff -u ~/a - This should show you in what way the two lists of files differ. diff shows the differences between two text files, and flag -u changes its output format: lines a...
How to determine the only additional file in otherwise two identical listings?
1,533,849,977,000
what do i have to do in the terminal in order to switch all the frontends of the xserver off, just to have the x window system running without any window manager or desktop environment?
You should kill your Display Manager to switch all frontends of the xserver off. It could be: mdm - MATE Display Manager gdm - Gnome Display Manager kdm - KDE Display Manager xdm - X Window Display Manager The corresponding one should be killed. E.g: sudo killall mdm To start a plain xserver you should type this com...
how to start into the x window server from linux mint ? [closed]
1,533,849,977,000
I'm using ifconfig on OpenSUSE. When I run ifconfig eth0 I get eth0 Link encap:Ethernet HWaddr CE:FD:75:DF:A5:6D inet addr:172.16.4.177 Bcast:172.16.5.255 Mask:255.255.254.0 inet6 addr: fe80::adfd:75ef:fedf:v56d/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:118...
You can start with sed 's/\(:[^: ]\+\) \([^(]\)/\1\n\2/g;s/\()\)/\1\n/;s/^ \+//' it should be close enough, and most probably can be simplified and optimized further. The result: eth0 Link encap:Ethernet HWaddr CE:FD:75:DF:A5:6D inet addr:172.16.4.177 Bcast:172.16.5.255 Mask:255.255.254.0 inet6 addr: fe80::adfd:7...
Formatting ifconfig using sed/awk
1,533,849,977,000
I use Fedora. There are a number of programmes packaged in a security spin. Included desktop files work but open the programmes with root priviliges. How can I edit the desktop file shown here to open the target without root. I have tried every obvious edit I can think of but am not having any luck. #!/usr/bin/env xd...
#!/usr/bin/env xdg-open [Desktop Entry] Name=argus Exec=gnome-terminal -e "sh -c 'argus -h; bash'" TryExec=argus Type=Application Categories=System;Security;X-SecurityLab;X-Reconnaissance; This matches behavior most closely. It could be improved upon by someone who knows argus better than I
.desktop file. Correct exec path
1,415,863,041,000
I use GNU Screen on occasion, and my Emacs keybinding muscle memory is hard to overcome. I know that I can send a control-a (i.e. "go to beginning of line") by hitting "c-a a", but I'm wondering if it's possible to remap the keybindings so that c-a c-a so that sends the c-a. I've tried a simple "bind ^a ^a" in the ...
You want: escape ^a^a or bind ^a meta (since meta sends the command character, i.e. here ^a). But since ^a is typically more useful than ^z in GNU Screen, you could use ^z as the command character. This is what I do: escape ^z^z
Gnu screen: remap "c-a c-a" to send "c-a"
1,415,863,041,000
I have recently finished a script that will ask for a hostname and automatically take the argument of the function and ssh into one of my work servers. Here is a copy of my script: #!/bin/bash echo "Provide hostname: " read host createSSHFunction() { arg1=$1 ssh $host } createSSHFunction $host while((1)); d...
If you can install the rlwrap utility, then it is as simple as doing rlwrap ./yourscript.sh This will allow you to use the up and down array keys to browse through history, as well as the right and left arrow keys for editing the current command, for programs that do not support it already.
Memory buffer in a bash script
1,415,863,041,000
How can I partition /dev/sdb into /dev/sdb1 and /dev/sdb2, and then format /dev/sdb1 to exFAT ( or FAT32 ) from LBA=1 to 2097152 by commands? ( LBA=0 is reserved for MBR )
I have created a loop device for testing: dd if=/dev/zero of=tmp.img bs=1M count=100 modprobe loop dd if=/dev/zero of=tmp.img bs=1M count=100 losetup /dev/loop0 tmp.img And then: # parted --script /dev/loop0 unit s mklabel msdos \ mkpart primary fat32 1 2048 mkpart primary fat32 2049 4096 print Warning: The resu...
How can I partition and format my disk to an accuracy of "LBA" by commands?
1,415,863,041,000
Hello I open my terminal window on Mac Os 10.6.8 as I am trying to update my ruby to 1.9.3 and the terminal gives me this response immediately as I open it: -bash: export: /Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier -bash: export:/Library/Frameworks/Python.framework/Versions/2.7...
OK, the main issue here was that you had spaces separating directory entries in your $PATH and that you had these spaces in non quoted variables which confused bash. What you wanted to do in this case was add a directory to your path. The correct syntax is PATH="/foo:/bar/baz:$PATH. Adding the $PATH to the end means ...
Bash Commands not working on Mac
1,415,863,041,000
Possible Duplicate: redirect output of a running program to /dev/null Is it possible to change stdout after starting something as a background application in the command line? Say I run test.py: import time while True: print "Hello" time.sleep(1) and then do: $ python test.py & Can I redirect the output...
Not unless you taught the program to do so somehow (say, on receipt of a particular signal such as SIGUSR1 it reopens sys.stdout and sys.stderr on /dev/null). Otherwise, once it's been started you have very little control over it.
Can I redirect stdout from a background application after starting it? [duplicate]
1,415,863,041,000
I have one file: combined.txt like this: GO_GLUTAMINE_FAMILY_AMINO_ACID_METABOLIC_PROCESS REACTOME_APC_CDC20_MEDIATED_DEGRADATION_OF_NEK2A LEE_METASTASIS_AND_RNA_PROCESSING_UP RB_DN.V1_UP REACTOME_ABORTIVE_ELONGATION_OF_HIV1_TRANSCRIPT_IN_THE_ABSENCE_OF_TAT ... and in my current directory I have multiple .xls files w...
xargs -I {} awk '$8 == "Yes" { title = title OFS $5 } END { print substr(FILENAME,1,length(FILENAME)-4), title }' {}.xls <combined.txt This uses xargs to execute an awk program for each name listed in your combined.txt file. The awk program is given whatever names is read from the combined.txt file with .xls added on...
How to grep all lines from one file in specific column in multiple other files?
1,415,863,041,000
[EDITED to reflect answers below] I am looking for a way to create blocks of folders / directories from the command line or a script that will generate a top level folder titled "200000-209999" and then inside of that folder, sub-folders named thusly: 200000-200499 200500-200999 201000-201499 ... etc ... ... etc ... 2...
The seq utility is one way to generate numbers: for start in $(seq 200000 500 209000); do mkdir "${start}"-"$((start + 499))"; done The syntax is seq start increment end.
Creating numerous ranges or blocks of folders/directories?
1,415,863,041,000
I want the shell to detect that I had run a specific command and then after running the command, run another command. For Example : When every I run the command : git commit -m " " First finish the above command and then run another command such as : python check.py I'm inclined towards modifying the .bash_rc file. Am...
Use the trap command in bash. trap [-lp] [[arg] sigspec ...] If a sigspec is DEBUG, the command arg is executed before every simple command ... Now your only problem is that your trap command is run before and not after the command. But you can refer the the command to be executed with $BASH_COMMAND, and you can cau...
How do I detect a command is being executed and then execute an additional command after the current command
1,533,768,388,000
I have a sample textfile(test_long_sentence.txt) below and I want to grep all the lines that contain test1 excluding unwanted data. How do I grep the data before the quote closes? test_long_sentence.txt This is some unwanted data blah blah blah 20 /test1/catergory="Food" 20 /test1/target="Adults, \"Goblins\", Elder...
Using awk $ awk '/test1/{line=$0; while (!(line ~ /[^\\]".*[^\\]"/)) {getline; line=line "\n" $0}; print line}' sentence.txt 20 /test1/catergory="Food" 20 /test1/target="Adults, \"Goblins\", Elderly, Babies, \"Witch\", Faries" 20 /test1/type="Western" 20 /test1/theme="Halloween" /test1/ is a condition. If the c...
grep till end of quote
1,533,768,388,000
I have a JSON file with thousands of records line by line in the following structure, with different values. Example: {"in": 5,"li": [{"st": 1508584161,"abc": 128416626,"ta": 33888}],"usr": {"is": "222108923573880","ie": "222108923573880"},"st2": 1508584161,"ei": {"ev": 0,"rt": 10},"rn": 947794,"st1": 1508584161} {"in...
With the correct numbers, a straightforward translation of you conditions works: $ jq -c 'select(.st1 <= .st2 and .st1 > 0 and .st2 > 0 and .st1 < 2147483647 and .st2 < 2147483647)' file.json {"in":5,"li":[{"st":1508584161,"abc":128416626,"ta":33888}],"usr":{"is":"222108923573880","i...
Using multiple wildcards in jq to select objects in a JSON file
1,533,768,388,000
Details OS: Solaris 10 , update 11 HW: M5-32 LDOM, V490, IBM x3650, T5240, VMware virtual machine, etc... EDITOR=vi term=vt100 tmp directory=/var/tmp cron shell=/sbin/sh My shell=/bin/bash Issue A very interesting error occurs when attempting to modify the crontab via crontab -e. If I attempt to search for a non-exist...
Not having the source to Solaris 10 or Solaris 11, I can't say for sure, but I suspect that Thomas Dickey is on the right track, based on his findings with vim. I tracked down the IllumOS source where a search for errcnt in the ex/vi directory shows that errcnt is only ever incremented, and errcnt is used as the retur...
Error while searching for non-existent string with EDITOR=vi crontab -e
1,533,768,388,000
I want to find and delete first 10 largest files. Below is the command to find out 10 largest files. du -a * | sort -n -r | head -n 10
Assuming the GNU implementation of all utilities below: find /some/folder -type f -printf '%s\t%p\0' | \ sort -rnz | \ head -10 -z | \ cut -f2- -z | \ xargs -0 rm -f
Find And Delete
1,533,768,388,000
I've been using rsync to synchronise folders and it works well. The problem is that more recently I've started syncing folders with larger files in them, and it takes much longer than I'd like it to (due to its hashing comparison). I've noticed that the cp commands can do one part of rsyncs job much quicker, by invoki...
This will (pretend to) delete any differences between the folders: diff -awr folderA folderB | sed 's/Only in //;s/: /\//' | while read f; do echo "removing ${f}"; done; If you want to remove differences in A but not B, you can add in a grep like so: diff -awr folderA folderB | sed 's/Only in //;s/: /\//' | grep "^fo...
Recursive comparison and deletion (without rsync or hashing)
1,533,768,388,000
Is there a way to cd out of a directory which has just been deleted (go up one level into the upper folder which still exists? It often happens to me that I have a console opened for a folder, and then I delete the folder with my temporary test data and create another one. However, both cd .. and cd $(pwd)/.. only ge...
PWD variable hold current path definition. to go up one level cd $(dirname $PWD) will expand to cd $(dirname /home/me/foo/bar/baz/deleteddirectory) who expand to cd /home/me/foo/bar/baz/ this supposed you delete only one level of dir.
cd out of deleted folder
1,533,768,388,000
I need to completely rebuild my boot partition. The file system has sda1 250mb for boot and sda2 lvm luks encrypted with ManjaroVG-ManjaroHome, ManjaroVG-ManjaroRoot and ManjaroVG-ManjaroSwap inside of it. I have the live usb I installed from originally if that helps. Currently the kernel panics when trying to boot re...
This is probably caused by a recent kernel update. Try getting into the boot menu and see if you can choose a different, older version of your kernel. Boot up with that one and it should be working ok afterwards. Please have a look over this thread: http://ubuntuforums.org/showthread.php?t=1751574&p=10780594#post10780...
How do I restore my boot partition manjaro/arch?
1,533,768,388,000
I'm trying to launch live(not ondemand) RTMP stream from ubuntu, but i succeed only with RTSP stream through VLC vlc -vvv ./videos/test.mp4 --sout '#rtp{dst=192.168.8.106,port=1234,sdp=rtsp://192.168.8.106:1234/test.sdp}' (source here - https://www.videolan.org/doc/streaming-howto/en/ch04.html) and unfortunately it...
After long research and tests finally i found the solution with vls+hls streaming ... vlc -vvv path/to/video/test.mp4 :sout="#transcode{vcodec=h264,vb=100, venc=x264{aud,profile=baseline,level=30,keyint=30,ref=1}, aenc=ffmpeg{aac-profile=low},acodec=mp4a,ab=32,channels=1,samplerate=8000} :std{access=livehttp{seglen=10...
Ubuntu live RTMP video streem
1,533,768,388,000
A command like dpkg -i *.deb will install all deb files in a folder without warning of incompatibilities and such. Can this command be changed so that installation of broken packages is avoided, warning displayed, etc?
incompatibilities and such What do you mean by that? Before installing, dpkg first checks if all dependencies of the .deb package(s) to be installed are satisfied. If the dpkg database is inconsistent, a message is printed.
Is there a dpkg argument to warn about incomptibilities/broken dependencies?
1,533,768,388,000
How can I configure a KVM guest running CentOS to allow passwordless console access from the hypervisor? I want to be able to use the following command to log straight in to the VM from the hypervisor without it prompting for a password: virsh console 1 The question is similar to this question, however the server in t...
You can possibly use PolicyKit rules to "unlock" libvirt for uids which are members of a specific gid-group. Here is another question, which does that for virt-manager (which like virsh console is based on libvirt). https://superuser.com/questions/548433/how-do-i-prevent-virt-manager-from-asking-for-the-root-passwo...
How to access KVM guest console without password?
1,393,264,983,000
I need to move a large number of files that need to go to different directories i.e. file1.mpg to /mnt/s3/directory1/file1.mpg file2.mpg to /mnt/s3/directorya/file2.mpg file3.mpg to /mnt/s3/directoryx/anotherfilename.mpg rsync -av --progress --inplace /path/to/file1.mpg /different/path/directory/1/file1.mpg Works b...
#!/bin/bash set -e R="rsync -a --timeout=10" $R file1.mpg /mnt/s3/directory1/ $R file2.mpg /mnt/s3/directorya/
rsync multiple files to multiple directories
1,393,264,983,000
How can I install the latest release of Mono in Ubuntu Saucy? In order to develop in a free OS, I need to setup Mono (that now supports .NET 4.5). This is what I did: Download and uncompress mono-mono-3.2.5 Run ./autogen.sh --prefix=/usr/local (finished ok) Run make, but it exit with error checking dependencies: ter...
It needed to have another instance of mono already installed, so apt-get install mono-gmcs did the job. Then, a new error appeared, and the only solution seemed to be using the GitHub package: git clone git://github.com/mono/mono.git cd mono ./autogen.sh --prefix=/usr/local make make install Now I have installed the ...
How to install Mono v3+ in Ubuntu?
1,393,264,983,000
Rainlendar is a great tool to keep events and tasks on the desktop (I did not find a better solution yet). The problem is that the application completely hides if you press: The "Show Desktop" button of Mint's panel (taskbar) Special-Key + d / CTRL + ALT + d Possible Rainlendar position settings: On Top - Does not ...
After trying a lot of different things, I ended up with this: Just do right click on the application's tray icon (usually a little calendar) and click "Refresh". This will make the application visible again. On Linux Mint with the Cinnamon desktop: The tray icon is only visible if the App Indicator Icon option is disa...
How to stop Rainlendar from hiding on the Linux Mint desktop?
1,393,264,983,000
I'm looking for way to process shell script arguments that is cleaner and more "self documenting" than getopt/getopts. It would need to provide... Full support of long options with or without a value after '=' or ' '(space). Proper handling of hyphenated option names (i.e. --ignore-case) Proper handling of quoted opt...
Since this question has been viewed so much (for me at least) but no answers were submitted, passing on the solution adopted... NOTE Some functions, like the multi-interface output functions ifHelpShow() and uiShow() are used but not included here as their calls contain relevant information but their implementatio...
Simpler processing of shell script options
1,393,264,983,000
I want to copy the whole log that are stored in the AWS S3 bucket if the following line is present: \"Key\" : 951332,\n I've tried escaping by trying this: aws s3 ls s3://bucket_name | grep "/\"Key/\" : 951332,/\n" --recursive but not getting anything back, does anyone know how I can run the grep in this manner?
Mount S3 using s3fs, then do..: grep -r Key /PATH/TO/MOUNT/POINT/ ... then pipe it through grep 951332 and check if that's enough resolution for your case. It might take a while and incur in AWS DataTransfer cost on you if you run this locally away from AWS, so you ideally want to run this from an EC2 instance in the...
AWS s3 CLi grep command with special characters
1,393,264,983,000
I recently started using linux mint. I am trying to execute the following command in my terminal sudo apt-get update . But I always get this output: How can I solve this issue? ... Ign:10 http://archive.canonical.com sarah/partner all Packages Ign:11 http://archive.canonical.com sarah/partner Translation-en_GB Ign:12...
First of all, note that apt-get update still updates its indexes as appropriate, it's just complaining that it can't download the information required for some of its repositories. sarah is a Mint code-name, not an Ubuntu code-name, so it makes no sense to try to use a sarah repository hosted by Canonical; you can saf...
Why am I unable to do a "sudo apt-get update"?
1,393,264,983,000
When tried the command cat < 1.pdf it printed a very large output, which was totally incomprehensible to me. The content of 1.pdf was abc. The output was like this: ÀýÓëöûcÎ=ÉÐÎTaüÍ8]ö¹mg:=Rú*@H1S¢▒ùá½~Ì8u_4,¬7ïy­t#¯ÚZ|åôÛ~«Æ fM²JKÁNÿ6 ì©ìÞ¾▒bT ¦åÊmBíöÖ¡÷ÄïÝM{Í1¹@;ÄqÄú t]È7DJ Êûc0£jÜÖã­\0O8À±(2)èJR'Ø...
If you call cat on a file containing a text in Chinese¹, it won't print out an English translation. With computer formats, it's the same thing: if you call cat on a file containing data in a certain format, it won't translate it to another format such as plain text. That's not its job: its job is to copy its input to ...
Why 'cat' can't read content of pdf files?
1,393,264,983,000
For debugging purpose sometimes I access a remote Linux box via VNC. At that time someone else may be working on that same Linux box through VNC and it may happen that I do not have facility to chat with that person. So essentially what happens is I start a new tab in the GNOME and type a message like this : [xxx@slc0...
End the line by pressing Ctrl+C. It will look like [user@box ~]$ Are you there?^C ETA: Ctrl+C sends the signal SIGINT, which in this context basically means "stop what I'm doing and give me back a prompt". It's just the same as when you're running a program from your prompt and pressing Ctrl+C - it will kill the runn...
Can I have the shell ignore the command line sometimes but not always?
1,393,264,983,000
Very often I need to use the sudo command because the command I'm running needs higher privileges. Is there some method to minimize the usage of sudo and/or a way to use it that's faster than typing my password, but which is still secure?
Many operations and programs do not in themselves need sudo, only for access to certain files. These files often also allow access for a group (e.g. /dev/mixer for group audio on my Debian), and you can avoid the sudo if you add your user to that group. The strace command is a good tool to find out which files are the...
Minimize need for sudo
1,393,264,983,000
I want to find the location of all files named index.php that contain the string "hello". thanks.
Using grep with find: find /top-dir -type f -name index.php -exec grep -l 'hello' {} + where /top-dir is the path to the top-most directory that you want to search. With -type f, we only look at regular files with find, and with -name index.php we restrict the search to files called index.php. -exec grep -l 'hello'...
How do I find the location of all files with a particular name whose content contains a particular string?
1,393,264,983,000
Let say that more users have a tmp directory in their home directory. I want to rename each tmp directory in each user home directory. What is the easiest way? Something like this: sudo mv /home/*/tmp /home/*/temp is not ok. And something like this: for dir in /home/*; do if [ -d $dir/tmp ]; then mv $dir/...
Perl comes with a rename(1) command that is installed on most Linux systems. On Debian-based systems it is in /usr/bin and for this case, you would use it like this: $ rename 's/tmp$/temp/' /home/*/tmp The first argument is a perl expression that acts on the subsequent arguments generating a new name. Each is then re...
How to rename directory from all user accounts
1,393,264,983,000
I'm trying to rename all files that start with an "m" to be the same name except with the first character (or "m" in this case) stripped away. My strategy is to: List all the files, with ls Filter for the ones I want, with egrep Generate the string I don't want next to the one I want, separated by a space, with awk, ...
ls | egrep '^m' | awk '{ x=$0; gsub(/^./, ""); $0 = x " " $0 }1' | xargs -l -t mv Posix-ly implementation is via the -L option to xargs as: ls | egrep '^m' | awk '{ x=$0; gsub(/^./, ""); $0 = x " " $0 }1' | xargs -L 1 -t mv ls | egrep '^m' | awk '{ x=$0; gsub(/^./, ""); print x, $0 }' | xargs -L 1 -t mv Based on wh...
How do I make a substitution to `$0` but save the old value?
1,393,264,983,000
I found What do the numbers in a man page mean? which explains the sections for command/library documentation quite nicely, and I was looking at the output for man regex and noticed the See Also referred to regex(3). I tried to run man 3 regex, but got the following message: No manual page for regex in section 3 My q...
REGEX(3) NAME regcomp, regexec, regerror, regfree - POSIX regex functions Works fine here on Arch Linux and also on the Internet... You might need to (re)install them: sudo apt-get install manpages manpages-dev manpages-posix manpages-posix-dev
No manual page for regex in section 3 - where is it?
1,393,264,983,000
I wanted to execute set -o vi, but instead I did set -ovi. Now when I checking set -o I see extra weird options such as: $ set -o set -o ... update_terminal_cwd; and as result, update_terminal_cwd; is printed on each command. How do I undo my typo without restarting shell?
If you did set -ovi then repeat as set +ovi the effect of one will be reversed by the other. What you actually did was activate the verbose option set -o v which shows history (if set) as well. The most important values set are printed by echo "$-", which is usually just himBH in interactive shells. A longer list of v...
How to undo typo `set -ovi`?
1,393,264,983,000
I have a large pipe-delimited file where I need to find the line number of all lines where a certain field is empty. I can use cut -d \| -f 6 filename.txt to output just that column. What is a utility/tool/command I can use to find what output lines from the above are empty?
# cut -d \| -f 6 test.txt | grep -v -E .\+ -n grep -v invert match -E .\+ match any 1+ character -n output line numbers
Get line numbers for lines with empty fields
1,393,264,983,000
I have MacOS and .bash_profile content: export PS1="\[\e[0;31m$\]\[\e[m\] \[\e[0;32m\w\e[m\] : \]" as a result I have pwd printed in terminal like this: but when I press up and down arrows to use terminal history I have bug:
no need to export PS1: it's a variable for the shell, other processes aren't going to use it. looks like you don't have the escaping brackets quite right. They are there to surround non-printing sequences, so bash can accurately figure how wide your prompt is. Try this: PS1="\[\e[0;31m\]\$ \[\e[0;32m\]\w\[\e[0m\] : "...
Bash prompt getting garbled when I browse history?
1,393,264,983,000
I have copied the rm executable from my machines "/bin/rm" to another linux machine that happens to be so minimal that it does not include the rm command. When I tried to execute the rm command I got this error: /bin/rm: /bin/rm: 1: Syntax error: "(" unexpected Why won't it work? How could I "add" the rm functionalit...
rm is a binary file and therefore architecture dependent. It would only work if you copy from the same architecture and with the same required libraries installed. Alternatively, you can compile it from source code or install the binary package. In Debian systems, it's a package. In case you already have a binary and ...
Why would a copied rm executable not work on another linux machine?
1,393,264,983,000
Is there a simple way to search a text file (source code) for all instances of a specific integer. This should not trigger on larger numbers that happen to include the integer as a sub-string, but it can't simply exclude such lines since they could contain both cases: searching for '6'... int a=6; // found int b=16; ...
grep -E '\b6\b' \b is a "word boundary" Edit: After pointing @nobar in the right direction, he found/pointed out the shortcut-option -w (word-regexp) in the manpage, which simplifies the above to: grep -w 6 If used a lot, you could use a function similar to wgrp(){ grep -w "$1" "$2"; } Note (to @glenn-jackman): If yo...
How to search a text file for a specific integer
1,393,264,983,000
I'm currently developing a home automation framework for my apartment. This involves getting JSON over Serial from an Arduino. When the JSON can't be parsed (usually only on startup) I log it as an error. Today something strange happened though, the broken JSON caused one of my terminals to become weird. [nodemon] re...
That happened because the output you produced included codes that your terminal interface interpreted as control codes. This is normally resolved with either reset or stty sane.
What can cause my shell to look like this? [duplicate]
1,393,264,983,000
I am fairly new to regular expressions and am looking for a sed/awk/grep/wc command to find the following in a pipe delimited text file the number of occurrences of the digit 1 after the 12th pipe. Here is an example of the text file: 2|JOHN||HAY||2955|ROSE|ST|#39D|Tool|TX|769065589|2542444320|||2222299310|SSD||01/08/...
I would use cut cat myfile.txt | cut -d '|' -f 12 | grep -c 1
Number of occurrences in a text file where first character after 12th pipe is equal to 1?
1,393,264,983,000
Is there an easy way to re-apply a previous command to a new command line entry? Say I typed in chmod u+r,g+x file.txt but forgot the sudo. Could I simply type sudo <some easy symbol>'?
You can do: sudo !! Another good one is alt ., to insert the last parameter of the previous command
Command to 're-apply' previous command?
1,393,264,983,000
I have a file with a number of lines in a file filename. I want to count how many lines start with character 'a', with 'b' and so on in one go. What command i should execute.?
Try this: <file.txt sed 's/^\(.\).*/\1/' | sort | uniq -c Or, if you want it case insensitive, this: <file.txt sed 's/^\(.\).*/\1/' | tr a-z A-Z | sort | uniq -c
Count how many lines start with which characters
1,393,264,983,000
I have big directory tree of files. I often use the find command to locate something in that tree. The first time after a reboot it takes some time, but subsequent uses are almost instant. Obviously find uses some internal datastructure that it has to recreate after a reboot. Is there a way to keep this datastructure ...
If your directory tree is relatively static (i.e. files and directories are created or removed infrequently), rather than find, you might try using locate. locate(1) General Commands Manual locate(1) NAME locate - find files by name SYNOPSIS locate [OPTION]... PATTERN... DESCRIPTI...
How to save the progress of the "find" command?
1,393,264,983,000
I wonder why a command that executes commands from a file in the current shell is named source. I can't see a relation between run commands in the current shell and the meaning of the english word source. Is there a history behind that name?
From Lexico, the Oxford Dictionary site: source VERB [WITH OBJECT] Obtain from a particular source. Isn't that exactly what this command is doing? Obtaining variable, alias and function definitions, and other shell settings, from a particular file?
Why does the command 'source' have that name?
1,393,264,983,000
I have images, I need to delete some files with the same size. But no need to remove all such images, but only the next in the queue (in alphabetical order): 1.png # 23,5 Kb 2.png # 24,6 Kb 4.png # 24,6 Kb > remove 8.png # 24,6 Kb > remove 16.png # 23,5 Kb
If you're on Linux or otherwise have access to GNU tools, you can do this: last=-1; find . -type f -name '*.png' -printf '%f\0' | sort -nz | while read -d '' i; do s=$(stat -c '%s' "$i"); [[ $s = $last ]] && rm "$i"; last=$s; done Explanation last=-1 : set the variable $last to -1. find ...
How to remove the same size files in a directory?
1,393,264,983,000
What's a single command I can run that shows me the total amount of space free on a hard drive? I don't want to do any math, I just want a command that shows me the total free space on my hard drive.
You can use df with the total flag --total produce a grand total df --total or df --total -h for human readable output (i.e K,M,G) This wil produce output such as Filesystem Size Used Avail Use% Mounted on /dev/sda2 23G 13G 8.7G 60% / udev 4.0G 124K 4.0G 1% /dev tmpfs ...
What command would I use to find out how much total space my hard drive has left?
1,393,264,983,000
I followed this tutorial to install FreeBSD 10.1 and at the step where it says "Add the following lines to /etc/rc.conf" I must to add the following lines in there: hald_enable="YES" dbus_enable="YES" performance_cx_lowest="Cmax" economy_cx_lowest="Cmax" But I'm new in Unix and I don't know how to add these lines in ...
You need to learn some sort of text editor. There are several available for FreeBSD like nano, ed, vi, emacs, and many others. I don't want to start a flame war so I'll encourage you to learn them on your own. If you want to get the really quick and dirty way to acomplish what your asking try: cat >> /etc/rc.conf << ...
How can I add lines in /etc/rc.conf?
1,393,264,983,000
I want to be able to search all available software like one would using "Synaptic Package manager" or "Ubuntu Software Center" through Command Line.` I want a better way than pressing Tab after typing a few letters after "sudo apt-get install ". It is not enough and can't search deep like Synaptic Package Manager.
You can use apt-cache search. For example to search firefox: apt-cache search firefox This is the according snippet from man 8 apt-cache: search regex [ regex ... ] search performs a full text search on all available package lists for the POSIX regex pattern given, see regex(7). It searches the ...
How to search for available software in repositories though CLI?
1,393,264,983,000
When I try to edit or assign the IP using this command: system-config-network-tui & Terminal opens a console which is uncontrollable, just like this: This happens on CentOS and Red Hat.
try not opening it as background process system-config-network-tui instead of system-config-network-tui & this has worked for me and later i switched to editing config files at /etc/sysconfig/network-scripts/
"system-config-network-tui &" doesn't work
1,284,113,005,000
I want to know about the "filter-command" which are available in Unix. I am confused regarding this: What is the purpose of "Filter-Command" ? Which are the Filter-commands available in Unix? I have read some books/articles on web, in some books i found few filter commands and in some books i found some other.
I'm not sure what you're asking without context. "Traditional" Unix tools read from standard input and write to standard output, so you can chain them together using a pipe, which is the | command: ls | grep "banana" | more Things which read from standard input and write to standard output are filters. There is an a...
Unix - Filter Commands
1,284,113,005,000
I have some .vcf files and I want to filter some variants out. This is just small part of my file: there are some header lines at the beginning of the file (starting with ##) and then variants (one row per variant). ##fileformat=VCFv4.2 ##source=combiSV-v2.2 ##fileDate=Mon May 8 11:32:53 2023 ##contig=<ID=chrM,length...
Here's a perl way: $ perl -F'\t' -lane ' if(/^#/){ print; next }; $F[7] =~ /\bSVLEN=(\d+)/; $svlen=$1; $F[7] =~ /\bSVCALLERS=([^;]+)/; @callers=split(/,/,$1); print if $svlen > 100 && scalar(@callers) > 1' file.vcf ##fileformat=VCFv4.2 ##source=combiSV-v2.2 ##fileDate=Mon May 8 11:32:53 2023 ##conti...
filter lines based on some criteria
1,284,113,005,000
I am asking why these three commands give three different answers: $ printf "%s\n" `echo ../.. | sed 's/[.]/\\&/g'` &&/&& $ printf "%s\n" $(echo ../.. | sed 's/[.]/\\&/g') ../.. $ printf "%s\n" "$(echo ../.. | sed 's/[.]/\\&/g')" \.\./\.\.
This is a tough question. The easiest example to explain in the last one. Fully quoted Well, actually, a fully quoted example: $ printf "%s\n" "$( echo "../.." | sed 's/[.]/\\&/g' )" \.\./\.\. Here there are no tricks nor changes done by the shell because everything is quoted. The most internal echo "../.." is...
Can someone tell me the difference between these three command substitutions?
1,284,113,005,000
What's the generic way to mute/unmute my system's default sound output? $ amixer set Master mute amixer: Unable to find simple control 'Master',0 $ amixer scontrols Simple mixer control 'IEC958',0 Simple mixer control 'IEC958',1 Simple mixer control 'IEC958',2 Simple mixer control 'IEC958',3 Simple mixer control 'IEC...
I've been using this command for ages now: pactl set-sink-mute @DEFAULT_SINK@ toggle This mutes/unmutes depending on the current state. Also to increase volume: pactl set-sink-volume @DEFAULT_SINK@ +3% or decrease volume: pactl set-sink-volume @DEFAULT_SINK@ -3%
How to mute/unmute default sound output
1,284,113,005,000
I have a strings in file: 7017556626 TEST BSAB 20191108 TEST123 3333 1111 BSAB 11 7007760674 TESTCHAS 20191108 TEST123 4444 5555 CHAS 22 7017556626 TEST 20191108 TEST123 3333 1111 CHAS 33 7017556626 TEST SSEQ 20191108 TEST123 2222 7777 BSAB 44 7007760674 TESTCHAS 20191108 TEST123 1111 0000 55 I need to add ...
With awk: awk 'substr($0,16,1) != " " { $0=substr($0,0,15)" "substr($0,16) }1' file If the string at position 16 is not a space character, change the current line to the prefix, space character and suffix. Then print the current line (1).
Add space before position in file
1,284,113,005,000
I'm doing some hands on pen testing and following some guides to get an understanding of the tools of the trade. I'm following along with the guide here and I understand everything except for the last page. I need assistance understanding sudo -l below. I know that it details what the current user can do. However, wha...
For your first question, the indicated lines of output are telling you that you are permitted to run /bin/tar and /usr/bin/zip via sudo as the root user without even needing to provide zico's password. For your second question, we get the answer from zip's manual page: --unzip-command cmd Use command cmd ...
Understanding sudo and possible exploit
1,284,113,005,000
I have two directories that both have a couple thousand files each, and I am trying to grep certain IPs from the files. My grep string is: grep "IP" cdr/173/07/cdr_2018_07* This grep string returns "grep: Argument list too long". However, when I do the following: grep "IP" cdr/173/06/cdr_2018_06* it returns what I a...
The shell is not able to call grep with too many files, or rather, the length of the command line1 for calling an external utility has a limit, and you're hitting it when the shell tries to call grep with the the expanded cdr/173/07/cdr_2018_07* globbing pattern. What you can do is either to grep each file individual...
grep works with one filepath, not another
1,284,113,005,000
Say I have these files: essay.aux essay.out essay.dvi essay.pdf essay.fdb_latexmk essay.tex essay.fls essay.toc essay.log ...... How do I rename them to: new_name.aux new_name.out new_name.dvi new_name.pdf ...
Here is a solution I was able to get working: #!/bin/bash shopt -s nullglob my_files='/root/temp/files' old_name='essay' new_name='new_name' for file in "${my_files}/${old_name}"*; do my_extension="${file##*.}" mv "$file" "${my_files}/${new_name}.${my_extension}" done shopt -s nullglob This will prevent a...
How to rename files with different extensions
1,284,113,005,000
I am trying to exit a while loop as soon as it returns no output. So if I am monitoring (with a while loop) the output of a command that changes, how do I exit the loop once the string I am monitoring no longer exists. (Say "purple" disappears from the output string in the example below) $ while :; do clear; "is_pu...
It's the last command in condition-list that determines when the while loop exits. while clear "is_purple_present_monitoring_script" | grep purple do sleep 15 done You could move the condition to the action-list and use break there (and use true or : as the condition-list) like with: while true do clear "...
How to exit a while loop
1,284,113,005,000
I declared a constant using define statement in my C file. #define COMPRESSION_VERSION 1.0.0 Now I have created libcompression.a library which includes the above C file. Now I need to check my defined constant value in the library using terminal.
#define COMPRESSION_VERSION 1.0.0 is a C pre-processor directive, which isn’t expected to survive macro expansion, let alone compilation. If you want a symbol that appears in your library, you need to add it explicitly; for example static const char * COMPRESSION_VERSION = "1.0.0"; This will then appear in your libr...
How to see constant values in .a lib files?
1,284,113,005,000
We have a CI server application run as the build user. Any command with arguments run by the CI server is visible via ps. Although non-admin users do not have access to load a shell on the CI server, they do however have access to running unix commands via a task. My concern is; user A can potentially expose a user ...
I'm afraid all commands are run as the build user. Then anybody who submits a build can see, and even interfere, with the jobs of another user. Running a build can execute arbitrary code; this allows anybody who submits a build not only to run ps but also to read and write files belonging to other jobs. If you can't...
How to stop a user from seeing command line arguments?
1,284,113,005,000
I have some very large tables and I need to extract specific rows. I am illustrating the task using a simple example. Say, I have weighed a number of apples, bananas and oranges. I need to extract the weight of the smallest apple, banana and orange Original table: Apple 3 Banana 8 Orange 2 Apple 7 Banana 9 Orange 13 A...
With awk: $ awk '($2<a[$1] || !a[$1]){a[$1]=$2}END{for(f in a){print f,a[f]}}' file Orange 2 Banana 1 Apple 3 a[$1]=$2 sets up an array called a, whose keys are the 1st field and whose value is the second. The script above will save the second field as the value for the first in the array if i) it is smaller than the...
Find the smallest numbers in the second column corresponding to index values in first column
1,284,113,005,000
Here is what I did less -N file1 > file2 what I want is writting file1 into file2 with line-numbers option. But I failed with that. Any suggestion to do that? Why I failed to do it? Thanks.
less is the wrong tool for the job. You can use cat for that: cat -n file1 >file2 Or nl: nl -ba file1 >file2 Or pr: pr -n -t -T file1 >file2 Or sed: sed '/./=' file1 | sed '/./N; s/\n/\t/' >file2 Or grep: grep -n . file1 | sed 's/:/\t/' >file2 Or awk: awk '{ $0 = NR "\t" $0 } 1' file1 >file2 Or again awk: awk '{...
Redirect output of less utility to a file
1,284,113,005,000
What is the most reliable way to give all users read/write privileges for a given directory, all of its subdirectories, and files in CentOS 7? In an eclipse web application project that uses Maven, I am getting the following compilation error in the pom.xml: Parent of resource: /home/user/workspace/MinimalDbaseExam...
You said you wanted to grant read and write permissions to all subdirectories and files under: /home/user/workspace/MinimalDbaseExample ... right? Octal 0777 permissions grant rwxrwxrwx symbolically. Octal 0755 permissions grant rwxr-xr-x symbolically. Octal 0666 permissions grant rw-rw-rw- symbolically. To set read/...
reliable way to give all read/write access recursively in CentOS 7
1,284,113,005,000
I have seen on many occasions a name of a function (frankly speaking I just call it function because of it typical appearance, they are though sometimes named commands or system calls but I do not know the idea behind labelling them differently), which contains a number within the brackets part of it, like in exec(1)...
exec here could be a system call or a bash built-in or something else from this . And respective man pages related to system call or bash built-in refer to the exec's man page with numbers in the brackets. So if I want to refer to manpage of bash built-in, I would say exec(1) and if I want to refer to manpage of syste...
What is the reason for having numbers within the brackets of a function ? [duplicate]
1,284,113,005,000
There have been multiple questions asked about this, like Understanding ls output, What are columns in ls -la?, What does 'ls -la' do?, What do the fields in ls -al output mean?, etc.. I've also come across many other websites with articles attempting to explain it. What every single one of them seems to have in commo...
ls is specified by POSIX, that’s the common reference. The output formats are described in the “STDOUT” section.
Where do I find documentation for the output of ls -l?
1,284,113,005,000
In Ubuntu 16.04, I'm trying to find a way to append the Day of the Week to the end of each line in a text file given the date in field 4. Sample data: Server ID,Make,"Server Room",Datestamp,Timestamp,Distance,Ping,Download,Upload,Payload,"Src IP Address",Hour,DOW x6883101,HP,"Server Room A",2019-07-14,04:50:02,26.444,...
With GNU awk, you could do: gawk -i /usr/share/awk/inplace.awk -F, -v OFS=, -v date_field=4 ' (t = mktime(gensub("-", " ", "g", $date_field) " 0 0 0")) > 0 { $NF = strftime("%A", t)};1' your-file -i /usr/share/awk/inplace.awk: enables the in-place editing mode of gawk, whereby the output is written into a new ...
Looking for a way to append Day of Week to end of line
1,284,113,005,000
At some point I used a shell command that continuously sent a very short string of text to the standard output, but at this moment I can't recall it's name. Its name was something very short, like 'abc', useful to quickly create a file filled with text. I remember I was surprised I had never seen it, so I guess it mi...
There's the command yes(1) yes - output a string repeatedly until killed
Linux command that continuously outputs string of text
1,284,113,005,000
In case of test -e for example: VAR="<this is a file path: /path/to/file/or/dir" test -e $VAR && do_something || do_anotherthing Question: Should I use "$VAR" here?, here I don't like verbose if not necessary, because $VAR obviously in this case is a path then if it's empty string it should always fail because there...
A general rule is to double quote any variable, unless you want the shell to perform token splitting and wildcard expansion on its content. because $VAR obviously in this case is a path then if it's empty string it should always fail [...] then with my logic, double quote it is not necessary. On contrary. The behavi...
Shell: only double quote on test -n/-z? [duplicate]
1,284,113,005,000
Is there a way to validate or confirm that the user wrote what it meant to write in read? For example, the user meant to write "Hello world!" but mistakenly wrote "Hello world@". This is very similar to contact-form validation of an email / phone field. Is there a way to prompt the user with something like "Please r...
With the bash shell, you can always do FOO=a BAR=b prompt="Please enter value twice for validation" while [[ "$FOO" != "$BAR" ]]; do echo -e $prompt read -s -p "Enter value: " FOO read -s -p "Retype to validate: " BAR prompt="\nUups, please try again" done unset -v BAR # do whatever you need to do with...
read value validation
1,284,113,005,000
I'm looking for a tool which automatically checks whether a LaTeX document is a correct bracket term. It's very easy to write such a tool but before I do, I want to know whether one already exists. It needs to be a command-line tool or shell code so I can use it in a script. A GUI tools just won't help me. It needs to...
With GNU grep built with PCRE support, you could do: find . -size +0 -type f -exec \ grep -zLP '\A((?:[^][<>{()}]++|<(?1)>|\{(?1)\}|\[(?1)\]|\((?1)\))*+)\z' {} + To find such files (assuming they don't contain NUL bytes and that each is small enough to fit whole in memory). Or call perl directly (allowing files wit...
Command-line tool for determining validity of bracket term
1,284,113,005,000
I have a text file with two columns and I want to print only the strings that are present in both of them. For example: column1 column2 stringA stringZ stringP stringT stringZ stringX stringE stringR stringT stringG Expected output: stringZ stringT
Shamelessly stolen from @cherdt with some improvement (assumes a shell like zsh or bash with support for ksh-like process substitution): f=filename; comm -12 <(cut -f1 < "$f" |sort) <(cut -f2 < "$f" | sort) Keeping filename in variable helps not repeat it No need to write to files, then to compare. Writing to files ...
Print string if present in two separate columns
1,284,113,005,000
I've found out the useful shortcut !! which can be used when you forget sudo before the command. You'll easily type $ sudo !! I've been doing this another way for a long time with up arrow, ctrl + home and type sudo. The advantage is, that you see the command. Would you recommend to change the habit and use rather !!...
Both ways have their pros and cons as you and Julie have noticed. But the really best solution is to use both of them when needed. So, when you're not sure of what !! will result in, first UpArrow to see what it was then DownArrow and then sudo !! There are more tricks regarding the history. This is from man bash. E...
Is it better to use !! or history?
1,284,113,005,000
I am given a txt file (war and peace..), and i need to create a text file sorted alphabetically of all the words that appear 10 or more times (without the quantity). The twist in this question, is that every punctuation is considered as a beginning of a new word, meaning you're is considered two words, you re. I flipp...
< text tr -cs '[:alnum:]' '[\n*]' | awk '++count[$0] == 10' | sort Replace $0 with tolower($0) if you want to ignore case. That translates sequences of characters that are the complement of the alphanumerical ones to newlines. awk prints the 10th occurrence of each. Note that on GNU systems, tr doesn't work prope...
Find in a text all words that appear 10 or more times
1,284,113,005,000
I am trying to sort a file as following which has multiple columns, separated with comma, and one of the column has date with the following format mm/dd/yyyy. $cat filename AN1143,45.7,03/05/2012, H9477,45.3,01/15/2010, DN1222,45.1,03/05/1800, J960,26.7,06/02,1990, Z959,28.2,03/21/2016, H12421,27.7,06/21/2000 My int...
Try this instead: sort -t, -k1,1 -k3.7n -k3.1,3.2n -k3.4,3.5n < filename There's no need to quote the comma delimiter The first sort-key definition uses column 1 The second sort-key definition uses column 3's "year" field, sorted numerically The third sort-key uses column 3's "month" field, sorted numerically The fo...
How to sort multiple column with a column including date?
1,284,113,005,000
I'd like to make fixed height output from any command using piping: some_command | magic_command -40 If, for example, some_command prints 3 lines, magic_command should add 37 newlines, or if some_command prints 50 lines, magic_command should cut extra lines (like head -40)
POSIXly: { command; while :; do echo; done; } | head -n 40 On GNU system: { command; yes ""; } | head -n 40
Padding output with newlines
1,284,113,005,000
I've looked around at multiple sources for this question and I know how to extract the file, but neither source told me how to state where to put the folder once it has been extracted. I tried this: tar -xvf tarball.tar.gz my/folder/im/extracting When I did this it seemed to extract it as it listed out it's contents,...
tar -xvf tarball.tar.gz my/folder/im/extracting This extracts the archive member my/folder/im/extracting at the location my/folder/im/extracting. If the archive member is a directory, its contents are extracted (including subdirectories, recursively). If you want to extract to a different directory, with GNU or Fre...
Extracting a certain folder from a tarball - how do I tell it where to put the file once extracted?
1,284,113,005,000
I have what looks to be a directory directory dir2, I once moved it from another directory dir1 to back it up and created a new dir1. Now I suddenly saw it again, realized I didn't need it and did rm -r -f dir2, and found out that my new dir1 is also empty. I got my files back (is was a code repository, so just some c...
It's impossible to know what happened given that the evidence is now deleted. Your descriptions of the symptoms is consistent with dir2 being a symbolic link to a directory. A symbolic link is a sort of special file that says “the real file is actually over there”. The symbolic link itself isn't a directory, so rmdir ...
rmdir dir gives error 'Not a directory'
1,284,113,005,000
Here is my initial situation: In a folder named for example Father, are stored some files in the following way: Father contains 24 children folders (let's call them Child1, Child2, ...), and each one of them has 2 files in it, file1.avi and file1.nfo for the first child, file2.avi and file2.nfo for the second one, etc...
The glob * can be used to match not only plain files, but also directories, so the command you are looking for is mv ./*/*.avi .
What command should I use to move these particular elements?
1,284,113,005,000
I would like to see the ifconfig file with test user (under Linux Debian) that's why I have used the sudo task, but the terminal said that: test is not in the sudoers file. How can I take the test user in the sudoers file? I've tried the /etc/pamd/su but it is not found?
The sudeoers file is usually located at /etc/sudoers. You need administrative privileges to edit this file. Editing it directly is strongly discouraged: you could irrevocably damage your system in case of syntax errors. The visudo tool is provided with the sudo package for safe editing. It will automatically check fil...
Add test user to the sudoers file, to run ifconfig
1,284,113,005,000
When I have a nested directory find . -name "*.py" -print command gives me all the python scripts beneath current directory. However, find . -name *.py -print returns only the python scrips in current directory. Is this expected behavior? What makes this difference? I use Mac OS X 10.7.
It's probably not the same command. You could put echo in front to check. $ echo find . -name "*.py" -print find . -name *.py -print $ echo find . -name *.py -print find . -name foobar.py barfoo.py -print Without quotes, the shell expanded *.py, so find gets different arguments, which yields different results. You s...
The difference that quotation marks make in find command [duplicate]
1,284,113,005,000
I get sometimes files with following ls output format: /etc/cron.d: -rw-r--r-- 1 root root 128 May 15 2020 0hourly -rw------- 1 root root 235 Dec 17 2020 sysstat /etc/cron.daily: -rw------- 1 root root 235 Dec 17 2020 sysstat Is there any chance using normal gnu tools or even clear bash internals to manipulate tha...
If none of your file or directory names contain white space then you could do the following using any POSIX awk: $ awk ' NF==1 && sub(/:$/,"/") { dir=$0; next } match($0,/[^[:space:]]+$/) { $0=substr($0,1,RSTART-1) dir substr($0,RSTART) } { print } ' file -rw-r--r-- 1 root root 128 May 15 2020 /etc/cron.d...
manipulate ls text output to add path to filenames
1,284,113,005,000
I have a bash for loop like this: for file in *.mp4; do command1 "${file}" && command2 "${file}" done This makes command2 to run whenever command1 is successful, which is expected. Now what I want is for the loop to wait only for command1 to finish , but no need to wait for command2 to finish before iterating. Is t...
A bit more verbose, but this should work: for file in *.mp4; do if command1 "${file}"; then command2 "${file}" & fi done
How to wait for the first command but not the second, where the two are joined by the && operator
1,284,113,005,000
I have a file containing multiple lines, with fields separated by tab: ID Code Date 1 XX 23/1/2018 1 XX 11/3/2021 2 XX 14/5/2011 2 XX 20/9/2013 3 XX 08/7/2014 3 XX 11/9/2016 3 XX 27/10/2018 I would like to keep for each participant ID just one entry, based on the entry with the earliest date in t...
Since you state that the records for each participant are ordered from oldest to newest, and you want to print only the record with the oldest date for each ID, this amounts to printing the first row encountered for each new ID. This is easily possible using awk: awk -F'\t' 'FNR>1 && !seen[$1]++' input.txt This will ...
How do I pick only one record per ID based on the earliest date in another column?
1,284,113,005,000
I have a rather long csh script that doesnt work, or doesnt work properly. in bash I would do set -xv to get verbose logging. what can I do in cshell? I tried adding set -xv it complained that - isnt allowed, and set xv didnt do anything.
You can use csh -xv script or you can add set verbose set echo to your script.
what is the csh equivalent of set -xv?
1,284,113,005,000
I wanted to copy all dotfiles from my ~ folder to a git repo to back them up, and I'm using ZSH. I came across this command that seems to work: cp -a ~/.[^.]* . - where the final . is the git dir. I don't understand how this works. Can anyone give me a guide, or tell me what to google to learn more? I tried ZSH + [^] ...
That syntax is for some shells other than zsh and even there, it would be wrong. .[^.]* matches on file names that start with . followed by a character other than ., followed by 0 or more characters. That's the kind of syntax you'd need in shells that include . and .. in the expansion of .*. . and .. are navigating to...
ZSH Globbing syntax explanation
1,591,436,750,000
I just want somebody to walk me through the steps of switching a command line interface linux box into a gui based one. I know this has to do with the X Window System but I don't exactly know how to go about installing it fully. Now, if firefox is installed for example and I try to run it, it will give me: "error: no ...
You say you are using Ubuntu. To add the desktop. You need to install it. However you say you are using Ubuntu 14.04 Ubuntu version numbers are YY.MM (year and month of release) see support has been dropped (it still has long-term security support until 2020-04). To install do apt install kde-plasma-desktop (or other ...
How to transform a CLI linux into a GUI one? Or at least how to run a gui app like firefox in CLI linux? Installing x windowing system?
1,591,436,750,000
I can pipe data from one command to another, example: $ echo test | cat test Unsure of what to call the operation I can get a similar effect using: $ cat < <(echo test) test Where <(echo test) is a bashism for creating a file on the fly. Using regular files it looks like: $ cat file test $ cat < file test This work...
I was able to get in contact with one of the pdsh developers and learned the following: What you want is "stdin broadcast" and unfortunately support for this was never added to pdsh. It would be a nice feature, but there was not historically much need for it, so it wasn't ever done. Which seem to confirm what ha...
pdsh input from file possible?
1,591,436,750,000
I use clipmenu to choose something to paste into terminal that running zsh as shell. Problem is that zsh will echo error when for example I paste a shell function that contains some # for comments inside that function. I have to manually go back and clear all lines contain #. System: archlinux/zsh/clipmenu EDIT: examp...
Perhaps you just need to setopt interactivecomments?
Zsh: remove # - comment when pasting to terminal?
1,591,436,750,000
Input text: test Online MD5 hashsum generator: 098f6bcd4621d373cade4e832627b4f6 echo "test" | md5sum: d8e8fca2dc0f896fd7cb4cb0031ba249 Also the same happens to sha512sum and sha1sum. Why does Linux and an online generator generate different hashes?
One of these is the hash of "test" and one of them is the hash of "test\n". $ printf 'test' | md5sum 098f6bcd4621d373cade4e832627b4f6 - $ printf 'test\n' | md5sum d8e8fca2dc0f896fd7cb4cb0031ba249 - echo outputs a newline character after its arguments.
Command line generates different hashsum than online hash generator… [duplicate]
1,591,436,750,000
i'd like to display the output of lsb_release -ds in my Conky display. ftr, in my current installation that would output Linux Mint 18.3 Sylvia. i had thought of assigning the output of that command to a local variable but it seems Conky doesn't do local vars. maybe assigning the output of that command to a global (sy...
You should prefer the execi version of exec, with an interval, where you can give the number of seconds before repeating: ${execi 999999 lsb_release -ds}
how to display lsb_release info in Conky?
1,591,436,750,000
Is there a CLI tool similar to gnome-search-tool? I'm using locate, but I'd prefer that it grouped results where directory name is matched. I get a lot of results where the path is matched which is not what I want: /tmp/dir_match/xyz /tmp/dir_match/xyz2/xyz3 It needs to be fast and thus use a search index.
locate is very versatile can take -r and a regexp pattern, so you can do lots of sophisticated matching. For example, to match directories a a0 a1 and so on use '/a[0-9]*/'. This will only show directories with files in them since you need the second / in the path. To match the directory alone use $ to anchor the pa...
Simple CLI tool for searching