Tag Info

New answers tagged

1

It is not possible to use the same file as input and output for grep. You may consider the following alternatives: temporary file grep pattern file > tmp_file mv tmp_file file sed sed -i -n '/pattern/p' file put whole file in the variable (not bright idea for large files) x=$(cat file); echo "$x" | grep pattern > file


1

When you do a simple export with HEAD, an internal timestamp is initialized based on the commit's timestamp. When you use more advanced filtering options, the timestamp is set to the current time. To change the behavior, you need to fork/patch git and change the second scenario, eg proof of concept: diff --git a/archive.c b/archive.c index 94a9981..0ab2264 ...


6

Process substitution results in a special file (like /dev/fd/63 in your example) that behaves like the read end of a named pipe. This file can be opened and read, but not written, not seeked. Commands that treat their arguments as pure streams work while commands that expect to seek in files they are given (or write to them) won't work. The kind of command ...


0

man pages are your friend. Whenever you see a command you've never used, run man [name of command] For example, man sudo will tell you: NAME sudo, sudoedit - execute a command as another user and, lower down: DESCRIPTION sudo allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers ...


0

sudo stands for substitute user do mkdir stands for make directory apt stands for advanced packaging tool The options like -r or -f are just random letters, but sometimes stands for real stuff. Like -u in ytdl stands for update, you can also run it using --update or -h which can also be run using --help Use man to get information about them.


3

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 to individual.sh via STDIN, not as an ...


0

This will print out the names of broken symlinks in the current directory. for l in $(find . -type l); do cd $(dirname $l); if [ ! -e "$(readlink $(basename $l))" ]; then echo $l; fi; cd - > /dev/null; done Works in Bash. Don't know about other shells.


4

alias tree="ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'" ls -R: list subdirectories recursively grep ":$": grep only for lines with : at the end of the line sed -e 's/:$//': remove : at the end of the line -e 's/[^-][^\/]*\//--/g': replace all path components except of last dir with --. To be precise replace any ...


2

Hitting Enter the script ends the process remains in the background. Almost! Actually, the script has already exited by the time you press Enter. However, that's how you can get your prompt back (because your shell prints its $PS1 all over again). The reason why hitting Ctrl + C terminates both of them is because the two of them are linked. When you ...


3

As Vivian suggested, the -t option of ls tells it to sort files by modification time (most recent first, by default; reversed if you add -r).  This is most commonly used (at least in my experience) to sort the files in a directory, but it can also be applied to a list of files on the command line.  And wildcards (“globs”) produce a list of files on the ...


0

You can perform substitutions in the previous command. This won't work with your {a, b} example, because all instances of 'a' will be replaced with a 'b'. But imagine you want to execute the following commands: run-command --a --whole --lot --of --parameter --format xml run-command --a --whole --lot --of --parameter --format son You can do it with ...


1

This does almost exactly what you want, except it leaves off the trailing / on the directory names. find . -maxdepth 2 -name file1.php -printf '%T@ %h (last modified %Td/%Tm/%TY %Tk:%TM)\n' \ | sort -k 1n | sed 's/^[^ ]* .\///' Credit where credit is due. This is adapted from shlck's answer here. Edit: All of my %A should have been %T


0

Will strip also empty lines grep -E -v "^\s*($|;)" php.ini


0

Yes it is quite possible. This will give you files which are modified in last 60 minutes: $ find /domain -type f -mmin -60 or this will give you files which are sorted by modify time. $ find /domain -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r Edit #1 If you have file extensions like you said '.php', add this: -name '*.php' And I found this ...


1

You can attack this in a variety of ways. Method #1 - alias You can make an alias, php=php-5.4, and then attempt to run your script. Assuming that it relies on the current shells ability to locate how to run things, then it should pickup the alias for php instead of the php that's located under /usr/bin. Method #2 - $PATH You can override the precendence ...


0

Alsa comes with speaker-test, a command-line speaker test tone generator, which can be used to generate a beep: speaker-test -t sine -f 1000 -l 1 See this arch linux forum thread. Unfortunately there doesn't seem to be an option to change the duration ("time per period").


2

Similar to @lgeorget's answer, this adds a newline before any ":61:" that is not at the beginning of the line: perl -pe 's/(?<!^)(?=:61:)/\n/g' file


3

Here is a very simple solution which works perfectly on your example: sed 's/ :61:/\n:61:/g' < input_file You may have to adapt it a little, especially if you don't always have a space before :61: in your input files.


3

The ifconfig command is not included in users PATH env variable. So you can either /sbin/ifconfig or modify the PATH variable to include sbin into your users path. Add the following line to your ~/.bashrc export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" source ~/.bashrc using, . ~/.bashrc or source ~/.bashrc or open e new terminal which will source ...


0

I don't have a MATE environment to test on but in general, this type of thing can be set using gsettings. Try this: gsettings set org.mate.panel.toplevel:/org/mate/panel/toplevels/bottom/ size 45 That should set the value you want. For more details, see http://wiki.mate-desktop.org/docs:gsettings.


1

There are patches for openssh for HPC (High Performance Computing) that improve ssh throughput by increasing transfer window sizes and disabling encryption - if you don't mind recompiling (and probably forward-porting patches), check HPN-SSH. As BowlOfRed noticed in the comment, you'd need to use the patches on both the client and the server. You can also ...


2

I wrote this quick script: #!/bin/bash ssh "$1" "nc -l 2020 > \"$2\" &" pv "$2" | nc "$1" 2020 It takes two args, the host to send it to and the file you are sending. It only works for one file. It uses ssh to start a netcat listening on the opposite end and then uses netcat to send it to that listening port. I added pv to the start to give a nice ...


3

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 file's consistency before saving and abort ...


1

w3m's imgdisplay library is able to display images directly. It only works on some terminal emulators such as Xterm and URxvt. ranger is a file browser that makes use of the library to display previews. Add this to ranger's configuration file to enable the feature: set preview_images true


1

If you happen to have installed imagemagick, you can use its very handy display command-line tool. display path/to/picture.png


2

I am not aware of any size limits for here-doc. I'm running kernel 3.9.1 and I've been experiencing the same issue here: when pasting large chunks of text in terminal some lines are truncated or missing. I found out (after some googling) that if you turn off line editing, pasting works fine (discussion here: Pasting large amounts of text into ...


1

I guess almost all Distros have a minimal version without GUI. Dont know any below 80MB, but I suggest the CentOS minimal, which is around 400MB. But there are distros below 80MB but they include both GUI and CLI. So I guess if 80MB is your limit you can use them and simply not use the GUI. Slitaz is just cool. Damn Small Linux (DSL) lol :D just 10MB.


0

You can Install "Ubuntu command-line system" and try Minimal CD. The command-line version of Ubuntu is a sparse system without any graphical elements. It's a text-only version of what lies underneath all the advanced graphical elements. It's also the starting point for a minimal installation. You can download following Ubuntu 32 or 64 bit minimal ISO ...


2

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 to) You can also retrieve information ...


0

You may also try using locate utility, e.g.: updatedb -o ~/tmp.db -l0 -U $PWD; cd $(locate -d ~/tmp.db -l 1 -b -r foo-) For more complex regex pattern check info locate.


0

Based on the final requirement you don't need cd; you can do the following: find . -type d -name 'foo-*' -exec make -C {} ';' and find . -type d -name 'foo-*' -exec phing -f {}/build.xml ';' The asterisks are handled by find internally, and I believe this is POSIX compatible.


0

Does drush mung backticks and vertical bars?  If not, you could use cd `ls | grep foo- | head -n 1` If backticks don't work, but |, $, ( and ) do, then you could change the above to cd $(ls | grep foo- | head -n 1) If | doen't work, but $, ( and ) do, then you could do cd $(myprog) where myprog is a script that you write to determine the directory ...


3

... | tee /dev/tty | ... /dev/tty is the "file" that refers to your terminal.


0

There are many CUE Splitters available online, however, most of them are only compatible with Windows. Usually, Mac users can't find a way to split CUE associated MP3, APE, WAV, FLAC, etc. What's more, most of CUE Splitters support splitting only one or two kinds rather than almost all common audio files with CUE sheet. You may prefer this step by step ...


3

Command line ranges can be use to select a specific line that needs to be edited. Then substitute pattern can be used to perform the edit (append). For example, to append text "hi" at the begining of line 3: vim -c "3 s/^/hi/" -c "wq" file.txt To append text "hi" at the end of line 3: vim -c "3 s/$/hi/" -c "wq" file.txt To find more options and ...


3

Generally applications that take too long to execute and dosent require user interaction are sent to background so that we can continue our work in terminal. Jobs running in background are treated same as jobs running in foreground except that their STDOUT, STDIN and STDERR varry. If you have a job that take too long, like file compression or backup you ...


0

If you execute an application that needs - let's say 5 minutes to end, for example a copy job - the shell is blocked while the program is running, the whole 5 minutes. The copy job is then in the so called foreground process group, indicated by a + sign in ps. You may need to do some other work during that 5 minutes, but the shell is blocked. On the other ...


0

Couple of commands that could help you on understanding it are, From any directory (assume /home/somedir), run the below commands. stat ./ - It will give out an inode number. find /home -inum inode_number - It will list the directory from where you originally executed the stat command.


-1

Short answer: just use less and forget about more Longer version: more is old utility you can't browse step wise with more, you can use space to browse page wise, or enter line by line, that is about it. less, is more + more additional feature you can browse page wise, line wise both up and down, search


0

Shells have two uses: to run scripts, and for an interactive command line. Dash is designed to be a fast, efficient shell for scripting. It has next to no nice features for interactive use. It doesn't have fancy prompts, command line edition, command history. It doesn't run a configuration file like bash's .bashrc when you start it interactively¹. You can ...


1

The command to set the system time is date. You need to be root to set the system time. date sets the time to the given time, not to a relative amount from the current time, because that latter behavior would be pretty pointless. You can build a command that modifies the current time by a relative amount by making a calculation on the output of date and ...


4

The easiest way to do that kind of thing is to use the shell's globbing and/or brace expansion features: cat linux.{0..3}.txt or cat linux.*.txt As others have explained, cat does not load the whole file into memory, it will just read a few bytes from it, print them to screen and repeat until everything has been read.


1

You can easily try things out for yourself and see if they are working without changing your current login shell. Apart from /etc/profile and ~/.profile, dash will read the file pointed to by an environment variable ENV when starting interactively so: ENV=~/.bashrc dash or better make a copy of your ~/.bashrc to ~/.dashrc and comment out/delete what you ...


3

Lots of the commands in your .bashrc are bash-specific. Things like HISTCONTROL aren't relevant to dash. Likewise for the command completion. Aliases will work however. Read the manpage for dash and check the manpage for each thing you're doing in your .bashrc to see whether it's applicable to dash. The real question you're asking is not very clear: do you ...


1

This one seems to fit the bill, it's free and open source and even works on Windows :) It even has advanced stuff, like instead of blindly picking any frame at the particular interval, it can pick ones that are close enough but don't look too blurry, so instead of doing this: You can pass it a parameter (-D6) so it does this: Plus I really like no ...


1

I just discovered this little program called puddletag. It is not as wonderful as Tag & Rename, but it's close enough.


1

To link with a library with a filename libad.a you link options to gcc should be: gcc abc.c -lad So you don't specify the extension, nor the starting lib part of the library file name. The output file will be a.out. You can specify extra search paths for the library with -L: gcc abc.c -L path_to_directory -lad


0

That was because the downloading was not complete, Although Chrome showed that it is complete I re-downloaded from another browser and it work fine now.


2

After seeing your CSV output, the problem is clear: you told Excel to use CR line endings, probably because it informed you that they are "Macintosh" style. That is badly outdated information, not true for over a decade now. There are three main line ending styles: LF: The style used by Unix and all its primary derivatives, including Mac OS X. CR: The ...


0

An “action in Linux's terminal” is presumably a command that you typed at a shell prompt. Typical shells record a history of past commands. In bash, the commands fc and history both display the history of recent commands; see the manual for available options. You can also navigate among past commands by pressing Up and Down, and search with Ctrl+R and ...



Top 50 recent answers are included