Tag Info

New answers tagged

0

You can use the find command's -exec option: cd Father find Child1 Child2 ... -name '*.avi' -exec mv -n {} . + The command breaks down as follows: find Child1 Child2 ... will find all files and directories under Child1, Child2, etc. The default action is to print their names -name '*.avi' will limit the result to files (or directories) that match the ...


0

For Debian: On my PC ~ > dpkg --print-architecture amd64 ~ > dpkg --print-foreign-architectures i386 My Raspberry Pi 2 ~ > dpkg --print-architecture armhf


6

The glob * can be used to match not only plain files, but also directories, so the command you are looking for is mv ./*/*.avi .


1

As mentioned before you can try picocom. The latest release (2.0) can also be used (safely) to set-up a "terminal server" since it does no longer permit shell commands injection. See: https://github.com/npat-efault/picocom/releases


1

Do you have to use awk for this? The paste utility was designed exactly for this sort of thing. Assuming array is a shell array: array=(100 200) printf "%s\n" "${array[@]}" | paste -d, input.csv - > output.csv The printf is simply to put each array member on a new line. paste then pastes together input lines from input.csv and - (i.e. the piped ...


0

The problem is that shell variables (including arrays) are not available inside awk. You need to pass them explicitly via -v option. Moreover you cannot pass the whole array, but you can put array into single variable and split it inside awk: awk -va="$(echo "${array[@]}")" 'BEGIN{OFS=FS=","; split(a,b," ")}{print $0,b[NR]}' input.csv This will work as ...


2

-exec indeed can be used as a predicate. find(1): Execute command; true if 0 status is returned. So this example would be: find . -type f -exec sh -c 'file "$0" | grep -q Matroska' '{}' ';' -and -delete Obviously, instead of -delete there can be -ls or -print0 or more predicates.


2

Screen is a full-screen software program that can be used to multiplexes a physical console between several processes (typically interactive shells). It offers a user to open several separate terminal instances inside a one single terminal window manager. The screen application is very useful, if you are dealing with multiple programs from a command line ...


1

If you want to open a new xterm and run a sequence of commands in that window, you can use the -e option. If you want the xterm to remain open after the command is executed, you can include the -hold option. For example: xterm -hold -e 'pwd; ls'


1

You can create a recursive script. eg in file /tmp/run #!/bin/bash depth=${1:-5} f(){ let depth-- if [ $depth -gt 0 ] then $0 $depth else sleep 10 fi } f then chmod +x /tmp/run and do /tmp/run 10.


2

The simplest way is to run: getconf LONG_BIT which will return 64 or 32 depending on whether it is 32 or 64 bits. eg: dannyw@dannyw-redhat:~$ getconf LONG_BIT 64


1

With zsh, to remove the regular files other than the .bmp, .png, .wav (case insensitively) ones: setopt extendedglob # best in ~/.zshrc rm -- *.^(#i)(png|bmp|wav)(D.) (remove the D above if you want to preserve hidden files regardless of their extension).


0

If you removed the directory you are in, cd .. will not work as the current directory exists without name and without connection to the rest of the world. So .. does no longer exist. Every bourne shell alike should allow to write a function that creates a copy of $PWD and traverses the path as far as it still exists.


0

Here's a sed solution using a sliding window (so there are never more than four lines in the pattern space at a time): sed '1{N;N};$!N;/.*\n.*\n.*Fail.*\n.*/{s/^/#/;s/\n/&#/g};P;D' infile On first line it reads in the Next two lines (so now there are three lines in the pattern space). Then, for each input line (including the first one) it pulls in the ...


4

On a GNU system, you can use this: sed -i '/^#[[:blank:]]Person/{n;s/#root:[[:blank:]]\+marc/root:\tsomeone@something.tld/;}' file It searches for a line beginning with # Person. Then switches to the next line and replaces #root:<blanks>marc with root:<tab> .... The -i flag edits the file inplace. -i, \+ and \t are GNU extensions. The ...


5

To go back by one level of directory based on the directory path rather than the .. link: cd $PWD:h Or the portable method: cd "${PWD%/*}" (quotes optional in zsh; quotes optional in other shells if the directory name doesn't contain whitespace or \[*?) Repeat the :h or /* as many times as desired to go further up in the directory hierarchy. ...


0

$ sed -r 'H;1h;$!d;x; s/\n([^\n]*)\n([^\n]*)\n([^\n]*Fail[^\n]*)\n/\n#\1\n#\2\n#\3\n#/g' file Name Number Reason = Pass Reasult Name Number Reason = Pass Reasult #Name #Number #Reason = Fail #Reasult Name Number Reason = Pass Reasult #Name #Number #Reason = Fail #Reasult Name Number Reason = Pass Reasult How it works H;1h;$!d;x These commands read the ...


1

I would suggest to use perl: perl -p0e 's/(.*\n)(.*\n)(.*Fail\n)/#\1#\2#\3#/g' file Here is how it works: -p: print program in the loop over all input lines -0: assume null as record separator -e: execute program from the command line s/x/y/g: substitute y for x anywhere in the file (): group together regular expressions .*: any character except newline ...


3

Assuming PWD is correct, one can back out in ZShell thusly. % cd ~/tmp % mkdir -p a/a/a/a/a/a/a/a/a/a/a % cd !$ cd a/a/a/a/a/a/a/a/a/a/a % rm -rf ~/tmp/a % undir % pwd /Users/jmates/tmp % The custom undir function does the walk-back-out-the-path-chain loop: function undir { local dir dir=$PWD:h while [[ $dir != / ]]; do builtin cd -q $dir ...


0

Java runtimes honor environment variables, you could set them in system startup files. Oracle Java uses _JAVA_OPTIONS, IBM Java uses IBM_JAVA_OPTIONS.


0

There is a project that works for several input files: split2flac From the project description: split2flac splits one big APE/FLAC/TTA/WV/WAV audio image (or a collection of such files, recursively) with CUE sheet into FLAC/M4A/MP3/OGG_VORBIS/WAV tracks with tagging, renaming, charset conversion of cue sheet, album cover images. It also uses ...


2

Assuming: hour=09 Just use that: grep "\.$hour" file With the single quotes in your example, the variable is not interpreted as variable. Therefore the pattern searches for $hour. Also the dot has to be escaped, else it would match any character.


0

I'm on fedora now yet I suggest you to read Archlinux's wiki carefully, all of it: Home and End keys not working. What I did to fix it: Press Ctrl-V Home, the escaped sequence for Home key is printed. It is not \e[4~ and \e[1~ as I expected to be by looking at /etc/inputrc. It was [H and [F Extract the terminal info infocmp $TERM >terminfo.src Open ...


3

A passphrase specified by -pass is different from the actual key for encryption specified by -K. openssl processes a passphrase with hash functions to derive an actual key with specific bit length. So passphrases are usually short and memorable strings using only printable characters. You can see actual keys, IVs, and salts by -P. Note that your key gets ...


0

Ok I found a solution, not exactly what I was hoping for, but it works. Install unclutter and use unclutter -idle 0 -root -jitter 9999 This hides your mouse. So the final approach is: xrandr --output HDMI-1 --brightness 0 unclutter -idle 0 -root -jitter 9999


1

You can use the shuf command to get a random number between a a range Numbers. Ex: $ shuf -i 70-100 -n 1 79 $ shuf -i 70-100 -n 1 72 $ shuf -i 70-100 -n 1 95 $ shuf -i 70-100 -n 1 96 $ shuf -i 70-100 -n 1 81 $ shuf -i 70-100 -n 1 78 $ shuf -i 70-100 -n 1 94 $ shuf -i 70-100 -n 1 78 $ shuf -i 70-100 -n 1 89 $ shuf -i 70-100 -n 1 81 $ shuf -i 70-100 -n 1 97 ...


0

There is no standard; some combination of man command, info command | less, command -h, command --help, command -help (ugh, Java), looking around for a README, altagoobingleduckgoing, etc. must be used, depending on the command, how good the vendor is about writing documentation (OpenBSD is very good in this regard, others well maybe yeah about that). ...


0

This is portable: a="$(command)" # Get the output of the command. b="????" # as many ? as characters are needed. echo ${a%"${a#${b}}"} # select that many chars from $a To build a string of variable length of characters has its own question here.


0

I've tried systemctl, update-rc.d and even editing the GRUB config, but nothing worked. Then I commented out the default display manager in /etc/X11/default-display-manager, rebooted and finally: the terminal!!!! It's as simple as that!


0

because you are taking input of less from somefile. it works like this 1 -> execute ls , as you have used pipe , it will pipe stdout to stdin of next command : this is what you are telling 2 -> it will look second command.. it is less < somefile as soon as it sees '<' redirection it will change stdin again to the file... Hence your previous change ...


1

What you can do is try to copy the .txt file to the documents directory. Then you can go ahead and delete the sub-directory. That would be 100X easier.


1

The only workaround I have is something along the lines of: # mess around extracting src/dest from install's $@ params # ... if [ -h $src ]; then rm -f $dest [ -d $(dirname $dest) ] || install -d $(dirname $dest) ...install args... $(dirname $src) cp -d $src $dest else install $@ fi The mess around extracting args bit is a pain in the...


0

Have you tried to configure local yum server and local repositories for it? If no then please follow this link, and just start from the YUM configuration. I have mentioned the steps below as well: For GUI interface in RHEL 6.2 follow below steps::: For GUI interface in RHEL 6.2 you have to install all the gnome packages of RHEL 6.2. Using rpm it is not ...


0

The above bash script by Ben Collins is a good solution, but he is missing the -p flag for the port on the server side. Running that as is would just give you an empty file or a hung server that never does anything. It's easier to see what this is doing if you just look at the commands. DestinationShell# nc -l -p 2020 > file.txt SourceShell# cat ...


0

Different commands support different option styles. The major trends are: getopt(): getopt() is a 30 year old programming API to parse options. It's widely available and the only POSIX standard. It only supports single letter options some of which can take arguments. Several options can be combined together for brevity. Example: tail -fn -2: an ...


0

If you use Oh My Zsh, there's a command called take that does exactly this. It would look something like this. take myfolder I actually found this one by accident. I just looked and it's listed on this cheatsheat from the Oh My Zsh GitHub wiki. It's quite a useful command, and apparently very easy to create yourself.


1

Maybe it's "cheating" but one option is pup, a command line HTML parser. Here are two ways to do it: Using the meta field with property="og:title attribute $ wget -q 'http://www.youtube.com/watch?v=Dd7dQh8u4Hc' -O - | \ > pup 'meta[property=og:title] attr{content}' Why Are Bad Words Bad? and another way using the title field directly (and then ...


0

If you did not tell cdrecord where to put the layer break, the drive will fill up the media up to 100%. This causes a long delay. If cdrecord fails, you may be a victim of various modified versions that ripped off DVD support and replaced the original code with something half baken. These defective versions do not report version 3 and they do not know about ...


0

A simple but very flexible tool for coloring ANY terminal text is 'colout'. pip install colout myprocess | colout REGEX_WITH_GROUPS color1,color2... Where any text in the output of 'myprocess' which matches group 1 of the regex will be colored with color1, group 2 with color2, etc. For example: tail -f /var/log/mylogfile | colout '^(\w+ \d+ ...


0

Publishes some time ago Node Js utility - log-color-highlight tail -f file | lch -red error warn -green success lch -f file -red.bold error warn -underline.bgGreen success


1

You have to do that in two steps: mv /Users/admin/Documents/Folder1/file1.txt /Users/admin/Documents/file1.txt rm -R /Users/admin/Documents/Folder1 With bash you can do the following shorter version: mv /Users/admin/Documents/{Folder1/,}file1.txt rm -R /Users/admin/Documents/Folder1


-2

Originally I had suggested this: cd /Users/admin/Documents/Folder1 mv $(ls -A) .. # the -A will find hidden items, but not return "." or ".." cd .. rmdir Folder1 But from the comments, I see that is not safe.


3

You can run bash inside find with -exec option and run file inside shell, e.g.: find . -type f -execdir bash -c 'file "$0" | grep -q Matroska && rm "$0"' {} \;


1

You can use lsof to see which processes are using a file. In your case: $ lsof /dev/dvb/adapter0 $ lsof /dev/dvb/adapter1 Each call will give you a list of the processes having requested a handler (file descriptor) to your device. If nothing is printed, you can conclude that your device is not currently in use. Here's an example with /dev/urandom, used by ...


-1

The way you would do this is simple grep ford stenton/gen_ed/cars2 | wc -m


5

You can use vi +$ /home/john/master/tried.cfg and do a way with the $() part completely. You don't have to escape the $ as it is followed by a space and bash doesn't expand it. You can also use this to go to, e.g. the one before last line: vi +\$-1 /home/john/master/tried.cfg but then you have to escape the $ with a backslash.


3

Eclipse doesn't need an installation. Simply run ./eclipse inside the folder. That's all. Or create the desktop file. In my example, the Eclipse folder is located in /opt/eclipse nano ~/.local/share/applications/eclipse.desktop and add the lines below [Desktop Entry] Type=Application Name=Eclipse Comment=Eclipse Integrated Development Environment ...


0

Sample pattern for multiple files (intersection in this case): eval `perl -le 'print "cat ",join(" | grep -xF -f- ", @ARGV)' t*` Expands to: cat t1 | grep -xF -f- t2 | grep -xF -f- t3 Test files: seq 0 20 | tee t1; seq 0 2 20 | tee t2; seq 0 3 20 | tee t3 Output: 0 6 12 18


0

Your problem is not with Jul, but with /, so remove them using for example parameter substitution mechanism: echo "Please enter the date: " read X a=$(date --date="${X//\//-}" '+%d-%b-%y') echo "$a" Please note that your variable assignment was also wrong (there must not be space after =) and command substitution should be enclosed with $().


1

If $x contains 14/Jul/2015, then use this: date -d "${x//\//-}" '+%d-%m-%Y' It will print: 14-07-2015 The date utillity doesn't understand the slash separated string, so you have to remove it and replace it with a dash (-).



Top 50 recent answers are included