Tag Info

Hot answers tagged

22

When using rm with both -i and -f options, the first one will be ignored. This is documented in the POSIX standard: -f Do not prompt for confirmation. Do not write diagnostic messages or modify the exit status in the case of nonexistent operands. Any previous occurrences of the -i option shall be ignored. -i Prompt for ...


20

One way to achieve this is by modifying the .bashrc file. Simply place the following at the end of the .bashrc file. PS1="\n$PS1" To explain how this works, PS1 is the variable containing what should be displayed as the prompt. All this is saying is "set PS1 to the previous contents of PS1, with a newline character prepended". Putting it in .bashrc on ...


17

Ctrl+4 sends ^\ Terminals send characters (or more precisely bytes), not keys. When a key that represents a printable character is pressed, the terminal sends that character to the application. Most function keys are encoded as escape sequences: sequences of characters that start with the character number 27. Some keychords of the form Ctrl+character, and a ...


10

You should not parse xml with sed, use an xml parser like xmlstarlet instead. For your task it would be: xmlstarlet ed -O --inplace --insert "/book" --type attr -n Book_Width -v A xml_file The file content is then: <book name="Sed tutorial" price="250" Book_Width="A"/> The ed means edit mode to edit the xml tree -O omits the xml tag We want to ...


7

You can use perl compatible regular expressions grep: $ pcregrep -M '(searchString.*\n)(?!.*excludeString)' file foo2 searchString bar foo3 searchString bar foo4 searchString bar It searches searchString followed by any char ., repeated zero or more times *, followed by new line \n only if there is not (?!) pattern .*excludeString next to it. Option -M is ...


7

There is no "precedence" for flags, each program handles them the way it wishes. Most do some effort to collect all flags and check for conflicts, for standard tools (like the referenced rm(1)) the relevant standards might mandate something (but then again, your particular version might be sloppy in interpreting corner cases of the standard/not get ...


6

Bug in the implementation of ext4 feature dir_index which you are using on your destination filesystem. Solution : recreate filesytem without dir_index. Or disable feature using tune2fs (some caution required, see related link Novell SuSE 10/11: Disable H-Tree Indexing on an ext3 Filesystem which although relates to ext3 may need similar caution. (get a ...


6

Yes, for rm this is valid. If the last option overrides previous ones however depends on the individual program itself. From ´info rm´ ‘-f’ ‘--force’ Ignore nonexistent files and missing operands, and never prompt the user. Ignore any previous ‘--interactive’ (‘-i’) option. ‘-i’ Prompt whether to remove each file. If the ...


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 .


5

You can use PROMPT_COMMAND: PROMPT_COMMAND="printf '\n';$PROMPT_COMMAND" or: PROMPT_COMMAND="echo;$PROMPT_COMMAND"


5

With sed: sed '/searchString/!d;$!N;/\n.*excludeString/!P;D' infile How it works: /searchString/!d deletes the line if it doesn't match searchString and reads in a new line, starting the command cycle over again (i.e. the remaining commands are no longer executed) if the line matches searchString, sed executes $!N;/\n.*excludeString/!P;D - see HERE ...


5

Try setting the COLUMNS environment variable. Works for me with man from mandb 2.7.0.2 on Debian with groff 1.22.3. $ COLUMNS=60 man apropos | head APROPOS(1) Manual pager utils APROPOS(1) NAME apropos - search the manual page names and descrip‐ tions SYNOPSIS apropos [-dalv?V] [-e|-w|-r] [-s list] [-m sys‐ ...


5

I'm not aware of such a flag to zip. You say: I do want to change the current directory to the parentdir by which I assume you mean you do not want to change to the parentdir. Under that assumption, I would use: (cd parentdir; zip -r ../output.zip .)


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.


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. ...


5

The command you ran created a symbolic link in the current directory. Judging by the prompt, the current directory is your home directory. Creating symbolic links to executable programs in your home directory is not particularly useful. When you type the name of a program, the shell looks for it in the directories listed in the PATH environment variable. To ...


4

In XFCE you can drag the icon of your desired application with your mouse to your terminal, you should see the name of the shortcut. This is what I got for Abiword: /usr/share/applications/abiword.desktop Then you can view this file with less /usr/share/applications/abiword.desktop, or just find the executable: grep Exec ...


4

You need to turn extglob on: shopt -s extglob


4

You can use the fmt command, which as far as I know is present in any Linux distribution. man apropos | fmt -w 70 will wrap up lines at 70 characters.


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 ...


4

In addition to Gilles answer let me add, that you can always input non-printable characters in bash with Ctrl-v+key (Ctrl-v+Ctrl+4 in this case) and check the character code with $ printf '^\' | od -An -tu # input ^\ as C-v C-4 28 you get the decimal code of the character, which as you may check in man ascii corresponds to file separator (FS).


3

in sed "a" appends a pattern IN A NEW LINE. what you want to do is replace (substitute). Let's use a colon as separator for clarity: sed 's:\(<book.*\)\(/>\):\1 Book_Width="A"\2:' anything in \( .. \) is a pattern memorized by the order of appearance and recalled by \indexnumber , e.g. \1 will reproduce the first pattern saved. So we are ...


3

Just use grep in this folder: grep "" *.id Output: 1.id:123 2.id:13 3.id:5 4.id:87876 BTW: I often use this in proc or sysfs filesystems; cd /sys/class/net/eth0 grep "" * This gives you all infos in sysfs about the ethernet interface eth0.


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 ...


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"' {} \;


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 ...


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 ...


3

Don't use which (unless you're in csh or tcsh variants), it's broken. Using command -v node instead. POSIX offer dirname command to get the directory portion of pathname: cd "$(dirname -- "$(command -v node)")" or using a variable to store the pathname, prevent you from calling dirname: nodepath=$(command -v node) cd "${nodepath%/*}"


2

xseticon allows you to do exactly that.


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



Only top voted, non community-wiki answers of a minimum length are eligible