date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,483,481,088,000 |
I am running a benchmark to figure out the number of jobs I should allow GNU Make to use in order to have optimal compile time. To do so, I am compiling Glibc with make -j<N> with N an integer from 1 to 17. I did this 35 times per choice of N so far (35*17=595 times in total). I am also running it with GNU Time to det... |
Because your graph showing the global efficiency provides the correct answer to your quest, I'll try to focus on explanations.
A/ EFFICIENCY \ JOBS PLACEMENT
Theoretically, (Assuming all CPUs idle at make launch time and no other task running and no i job has already completed when launching the n-th > i), we may expe... | Spike in number of page faults with make -j`nproc` |
1,483,481,088,000 |
I would like recipes in GNU Make to use environment variables instead of command line arguments, to make them shorter, so that I can concentrate better on what changes in each command. For example, instead of seeing:
g++ -g -I/path1 -I/path2 -DFLAG -Wall -c hello.cpp -o hello.o
I would like to see something like:
g... |
You might want to use a so-called compiler response file which is very common in MS toolchains. Apparently recent versions of GCC also support it (see the manual).
CXX = g++
CPPFLAGS = -I/path1 -I/path2 -DFLAG
CXXFLAGS = -g -Wall
CXXOPTS = $(CURDIR)/cxx.opts
%.o: %.cpp $(CXXOPTS)
$(CXX) @$(CXXOPTS) -c -o $@ ... | Using environment variables for shorter recipes in GNU Make |
1,483,481,088,000 |
I'd like to use the shell assignment operator (i.e., !=) in a makefile that is going to be executed on FreeBSD, macOS, and Linux. Here's an example:
a!= seq 3
.PHONY: all
all: $a
.PHONY: $a
$a:
@echo $@
Here's the expected output:
$ touch 1 2 3
$ make all
1
2
3
Unfortunately, the shell assignment operator is ... |
The solution is to use the $(shell ...) construct in addition to the shell assignment operator like this:
a= $(shell seq 3)
a!= seq 3
.PHONY: all
all: $a
.PHONY: $a
$a:
@echo $@
The GNU Make 3.81 seems to skip the shell assignment so it uses the output of the first assignment. bmake, however, does not really ca... | How do I use a shell assignment in a makefile so that it works with both FreeBSD make (bmake) and macOS make (GNU Make 3.81)? |
1,483,481,088,000 |
I have these lines in my Makefile:
PLATFORM = $(shell uname -r)
OLD_FREEBSD = 7.3-RELEASE-p2
ifeq ($(OLD_FREEBSD), $(findstring $(OLD_FREEBSD),$(PLATFORM)))
...
do some stuf... |
You can compare a string (a word) to several others with filter, which returns any that match the word. For example,
...
OLDER_FREEBSD = 7.2-RELEASE-p2
M = $(filter $(PLATFORM),$(OLD_FREEBSD) $(OLDER_FREEBSD))
ifneq ($(M),)
...
| Check FreeBSD version in Makefile |
1,483,481,088,000 |
I have this rules in my GNU Makefile:
FITXER = fitxa.md
$(FITXER).html: $(FITXER)
pandoc --from markdown --to html $(FITXER) -o $(FITXER).html
$(FITXER).jpeg: $(FITXER).html
wkhtmltoimage $(FITXER).html $(FITXER).jpeg
Is there any way to apply this rules in a list of files: for example something like that (... |
The way to go about this is to define general build rules:
%.html: %.md
pandoc --from markdown --to html $< -o $@
%.jpg: %.html
wkhtmltoimage $< $@
This tells make how to create HTML files from Markdown files, then how to create JPEGs from HTML files.
Once you've done that, all that's needed is to tell make ... | apply rules in a list of files in GNU Make (or 'for' instruction in GNU Make) |
1,483,481,088,000 |
Which directories should I expect to have in an install prefix when I'm writing makefiles? I've noticed that in the common prefix /usr, there is no /etc, yet there is an /include dir, which isn't in the root directory. Which paths are hard-coded such as /etc and /var maybe and which directories lie in a prefix? As far... |
See the FHS (Filesystem Heirarchy Standard) for details: http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard and http://www.pathname.com/fhs/
| What do I install into a given install prefix |
1,483,481,088,000 |
I have this Makefile where I'm having some troubles on simply set some variables:
my_stage:
echo "FULL_NAME=$(FULL_NAME)"
echo "MY_NAME=$(MY_NAME)"
$(eval SOME_NAME=$(shell sh -c "echo ${FULL_NAME} | cut -d"-" -f 2"))
echo "SOME_NAME=$(SOME_NAME)"
$(eval NAME_ONLY=$(shell sh -c "echo ${SOME_NA... |
When you use curly braces, like ${FOO}, in your command, you refer to a a shell variable, as defined in the shell invoking make.
When you use parens, like $(fOO), in your command, you refer to the make's variable.
Since you only set make's variables, obviously references to shell variables of the same name would resul... | Makefile - Set multiple variables on a single stage |
1,483,481,088,000 |
To embrace the DRY (Don’t Repeat Yourself) principle, I sometimes need to share pieces of shell commands in a Makefile. So there is a recipe somewhere in that file like:
shell=/bin/bash
# …
.ONESHELL:
run:
# Create bash sub-shell «cmd» var, holding a built-in test as a string
@cmd='[ $$(grep -iE _dev </etc/hos... |
Variable and command substitions in the shell occur after deciding on command boundaries, and parsing redirections (and assignments). You can put a program name and/or arguments in a variable and substitute them, but not pipes or redirection or other substitutions including $( command ) or assignments or shell keyword... | Makefile, sqare brackets built-in, variable expansion and command substitution |
1,483,481,088,000 |
I have several Git repositories with LaTeX files that I want to have typeset automatically. The idea is to have a central bash script (run by a cronjob) that executes a bash script in every repository, which (1) pulls new commits and (2) executes make all, which should call latexmk on the changed LaTeX files.
The cent... |
The problem turned out to be that the path to pdflatex was being defined in my $HOME/.profile. I thus changed the cronjob to:
* * * * * . $HOME/.profile; bash .../cron.sh 2>&1 > .../cron.log
in accordance with https://unix.stackexchange.com/a/27291/37050.
| Latexmk, from Makefile, from bash script, from Cron - Latexmk not being executed |
1,483,481,088,000 |
I want to simulate Tiago robot in Gazebo and I am using ROS available package. Before, I simulated it without problem but right now I can not. I am using ROS melodic and ubuntu 18.04 on KVM virtual machine. When I use catkin_make command to build the workspace, the below error happens:
[ 1%] Built target _tiago_pick_... |
You're running out of RAM, so badly that your operating system kills your compiler.
So, reduce the parallelism, or assign more RAM to the building VM.
| Invoking "make -j16 -l16" failed |
1,483,481,088,000 |
I was reading a makefile where I found this statement
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
Can anyone explain what is shell here. Command substitution is being tried here but for that only uname -r would have been sufficient. Why is shell word being used and what is its meaning?
I have alr... |
I bet this line is within a Makefile, most likely a recursive call to make.
Makefile use $(VAR) (or ${VAR}) for local variable or environment variable.
note the difference with bash where $(VAR) means "execute VAR and fetch result", thus for similar effect in Makefile anoter syntax is used
$(shell uname -r)
to sum up... | What is the meaning of shell in $(shell uname -r) |
1,483,481,088,000 |
I'm using gnu make and stow to manage some configurations (dotfiles).
I have multiple directories in my repo:
dotfiles/
├── Makefile
├── package1/
└── package2/
Currently, my Makefile looks like:
PACKAGES = package1 package2
.PHONY: all $(PACKAGES)
all: $(PACKAGES)
package1:
stow --no-fold $@
package2:
st... |
You could replace your rule with:
$(PACKAGES):
stow --no-fold $@
| Make pattern match directories |
1,483,481,088,000 |
I have the makefile below.
Why does the rule for the data/vix.csv target always execute when I run make, though?
In a recent answer on SO, someone showed me how to update last_updated.txt on 24 hour intervals, even if I was running make frequently. As a result, @echo "\n\n##### updating last_updated.txt#####\n\n" rare... |
Run ls -l data/vix.csv to see the actual timestamp of data/vix.csv.
Does it reflect the time you last ran make and saw the downloading fresh data and updating vix.csv message?
Or does it reflect the timestamp of the source material, wherever Rscript update_csv.R gets it from?
Or does it actually get updated at all?
| why is this makefile command running so frequently |
1,483,481,088,000 |
I have tests in tests/FILENAME-test.sh and for each one I want to run the script inside a docker container.
How can I refactor this Makefile to not use TEST_OUTPUTS like I have?
Also, how can I make each docker run command run in parallel?
.PHONY: test image
TESTS=$(wildcard tests/*-test.sh)
TEST_OUTPUTS=$(patsubst %... |
Here it is:
.PHONY: test image
TESTS=$(wildcard tests/*-test.sh)
test: $(TESTS)
$(TESTS): image
@sudo docker run -t box-test /bin/bash "-c" "./$@"
image:
@sudo docker build -q -t box-test .
And for the docker run commands to run in parallel, just use make -j test (you may specify a maximum number ... | How can I refactor this Makefile to not use fake .out outputs? |
1,483,481,088,000 |
According to FreeBSD, from version 10 they use Clang/LLVM instead of gcc. on the surface of it all things should perform as been before even better. but I have faced this reality more than I want to. Some codes can't be compiled this way.
For example I tried to compile Snapwm. First native FreeBSD make is actually pma... |
Sometimes needs some patch. I've createad which you can apply and can build with gmake. I didn't try the compiled snapwm I've tested only building process.
diff -ur Nextwm-master.orig/Makefile Nextwm-master/Makefile
--- Nextwm-master.orig/Makefile 2014-03-12 19:46:34.000000000 +0100
+++ Nextwm-master/Makefile 2014-04... | Building Snapwm on FreeBSD (Problem of gcc and clang)? |
1,483,481,088,000 |
An app is trying to configure with
sudo make configure
(cd /opt/ioapi-3.2/ioapi ; sed -e 's|IOAPI_BASE|/opt/ioapi-3.2|' -e 's|LIBINSTALL||' -e 's|BININSTALL||' -e 's|IOAPI_DEFS||' -e 's|NCFLIBS|-L/opt/netcdf/lib -lnetcdff -L/opt/netcdf/lib -lnetcdf|' -e 's|MAKEINCLUDE|include /opt/ioapi-3.2/ioapi/Makeinclude|' -e '... |
Looking at the Makefile.template file of the ioapic-3.2 project on GitHub, it is clear that the sed command that you are seeing is the result of make using the SEDCMD variable:
SEDCMD = \
-e 's|IOAPI_BASE|$(BASEDIR)|' \
-e 's|LIBINSTALL|$(LIBINST)|' \
-e 's|BININSTALL|$(BININST)|' \
-e 's|IOAPI_DEFS|$(IOAPIDEFS)|' \
-... | Error when using Makefile..sed |
1,483,481,088,000 |
I have a small application that was tested on Linux and it worked. Now I would like to build the same code on FreeBSD. To build it on FreeBSD I needed to change a little my Makefile. Here is my amended version:
CXX := gcc
LDFLAGS += -L/usr/local/lib -R/usr/local/lib -L/usr/lib -R/usr/lib -L/usr/local/include -R/usr/lo... |
I replaced gcc with c++ and now it works.
| FreeBSD - problem with linking protobuf |
1,298,696,585,000 |
I'm currently adding a little bit of Git functionality to my menu.vim file, and for using a certain command (Gitk) I need to find out Vim's current directory.
How does one do that and include it in a command? (i.e. :!echo "%current-directory")
I'll admit here that I asked the wrong question - but I figured it out.
I'... |
I think either :pwd or getcwd() is what you are looking for.
Just to help memorize things:
:pwd => print working directory
getcwd() => get current working directory
| Vim - Get Current Directory |
1,298,696,585,000 |
Several tools such as grep, py.test, etc ... use the pattern <FileName>:<line number>: to point to errors. For example:
; grep -Hn Common setup.cfg
setup.cfg:11: Common
How can I modify vim and gvim so that I can invoke them like so:
gvim setup.cfg:11:
instead of
gvim setup.cfg +11
I know that I can write a sm... |
You can use the file:line plugin available here, which does exactly what you want...
| vim - open file and goto line number using <filename>:<line nbr>: |
1,298,696,585,000 |
In vim you can open a file under the cursor by using the gf command.
One can also easily open that file in a new split window by hitting <c-w> f. This is a really nice and time saving feature.
However, I can't figure out, how to open the file in an already opened split window (without creating a new one).
|
I got all the pieces together to do the trick. The best way is to create a custom mapping for all the commands:
map <F8> :let mycurf=expand("<cfile>")<cr><c-w> w :execute("e ".mycurf)<cr><c-w>p
Explanation:
map <F8> maps on "F8" the commands that follow
let mycurf=expand("<cfile>") gets the filename under the cur... | vim shortcut to open a file under cursor in an already opened window |
1,298,696,585,000 |
I'm used to modeless editors. Only the past year I've been using vim/gvim, which has a modal approach.
I'm used to tabs in all editors, since before vim all of them are used to it. In gvim, you don't necessarily need to use tabs: you can just use buffers.
My question is: what are the advantages/disadvantages between t... |
See https://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers/103590#103590 (or why spliting the vim community among all SE/SO sites is a bad idea)
| Buffers or tabs in vim? What are advantages/disadvantages of each approach? |
1,298,696,585,000 |
I'm working on a side project with both JavaScript and SQL source files. When I'm editing the JavaScript, Vim behaves normally. However, when I'm editing the SQL files, there's about a one-second delay between when I press CtrlC and when Vim exits insert mode. When I use the Escape key, or ShiftEnter which I mapped in... |
You seem to have a filetype plugin that installs a buffer-local mapping for Ctrl-C. You can check with
:verbose imap <buffer> <C-c>
It's probably the default one, cp. :help ft_sql. The prefix key can be reconfigured via this (in your ~/.vimrc):
let g:ftplugin_sql_omni_key = '<C-j>'
| Vim delay when using Ctrl+C, but only in SQL files |
1,298,696,585,000 |
I have to use Ubuntu 10.04 at work, and can't upgrade it. I'm using Vim/gVim 7.2.
I want to upgrade it to 7.3 (with Python and Ruby extension support). Which is the best way? Add an entry in sources.lists and install a 7.3 vim/gvim package from it, or build from source? What disadvantages would I have from each approa... |
The first place to check is if there's a backport, but there isn't, which isn't surprising since maverick has vim 7.2 too.
The next thing to try is if someone's put up a repository with vim 7.3 packages somewhere, preferably a PPA. There are many PPAs with vim, including several with
7.3 (not an exhaustive list).
If y... | Best way to upgrade vim/gvim to 7.3 in Ubuntu 10.04? |
1,298,696,585,000 |
I often use Control+L to redraw the screen in Vim.
In particular, when I come out of sleep or change monitor configurations I often find that Vim needs to be redrawn. I thought it might be simpler to just add something to my vimrc that redraws on focus.
Is there a command that I can add to my .vimrc file that redraws... |
vim has an event you can bind to for this, FocusGained, combine this with the redraw! command (the ! causes the window to be cleared first)
:au FocusGained * :redraw!
The syntax here can be read as 'automatically run the command (au is short for autocmd) :redraw! when I get the event FocusGained for any file matchin... | How to automatically refresh Vim on buffer/window focus? |
1,298,696,585,000 |
Should I install vim or GVim ?
I develop mainly Ruby on Rails (I also use IDE's, but different topic).
Are there any differences or advantage of using Gvim vs vim ?
|
In gVim you can select the font, vim depends on the font the terminal provides. And it's the same for colour support. Gvim has full support, vim depends on the terminal.
Gvim additionally has menus and a toolbar, which vim lacks.
One big advantage of vim is that, since it's a terminal application, you have a full fled... | Advantages (or downsides) of GVim over Vim to edit code [closed] |
1,298,696,585,000 |
I search a pattern, say 'START OF ARAMBOL' and it is matched in a file. Now I would like to comment every line from the line no 1 to the current matched pattern line no. I have to do it for more than 200 files.
I can do this using perl too but is there any good sed method to do so.
Thanks
|
As a one-liner to demonstrate the concept :
echo -e 'a\nb\nc\nPATTERN\nd\ne\nf' | sed '0,/PATTERN/ s/^/#/'
You just have to adapt to your context :
as for the 'PATTERN'
I assumed '#' as the commenting character
and regarding how you can apply this to all your files. If they all are 'fileXXX.txt', you can run : sed -... | Comment from start of file to a pattern matched line using sed |
1,298,696,585,000 |
Powerline is some sort of plugin for Vim and Gvim. In order to be more useful it uses fonts that has some pictures (symbols) added to them. In other words they've "patched" the font set. Recently Powerline stated that the code has been changed and you have to patch your fonts again. The link to the same can be found h... |
The patch script is accessible here in it's own GitHub repo, titled: powerline-patcher.
An experiment
I first started by downloading the above patching script.
$ git clone https://github.com/Lokaltog/powerline-fontpatcher.git
I then selected a sample .ttf file to test out your question.
$ ls -lr | grep ttf
-rw-r--r--... | Can we patch an already patched font? |
1,298,696,585,000 |
When opening a new tab in gVim (with :tabe), the status line at the bottom of the screen disappears. If I press : and start typing a command I can no longer see the command on the status line.
When the gVim window is maximized, opening a tab pushes the status line below the screen. When the gVim window is not maximi... |
This happens to me as well. The workaround that I use is to minimize gVim then maximize it again. After that the status bar is visible again.
Bug is described here: https://bugs.launchpad.net/ubuntu/+source/vim/+bug/137854
Bug is reported fixed in debian, but the issue is still there with Ubuntu 11.04 (Natty)
| gVim opening a tab pushes status line out of window |
1,298,696,585,000 |
How can I remove a line with a specific word but keeping in mind: if another word is found, then don't delete the line.
For example, I'm deleting a line having sup or gnd with :%s/.*sup.*//g or :%s/.*gnd.*//g, but it is also deleting some lines which is breaking breaking loop line as well.
I don't want to delete lines... |
You could use:
:v/module/s/\v.*(sup|gnd).*//
:v/pattern/cmd runs cmd on the lines that do not match the pattern
\v turns on very-magic so that all the (, | characters are treated as regexp operator without the need to prefix them with \.
Note that it empties but otherwise doesn't remove the lines that contain sup o... | How to delete a line which contains a specific syntax but I want to avoid a line which contains another word |
1,298,696,585,000 |
In gvim editor how to split the editor window horizontally? so that includes two files and can see simultaneously
?
|
From command line:
open specified files as horizontal splits
gvim -o report.log power.log area.log
open specified files as vertical splits
gvim -O report.log power.log area.log
Within the editor
open file for editing in new horizontal split screen
:split filename
:sp filename
open file for editing in new vertical s... | splitting the gvim editor window horizontally |
1,298,696,585,000 |
I would like to run vim via X11 (over SSH). Vim comes pre-installed on my NAS (running Debian), however the GUI is not.
When I run vim -g, I get this error:
E25: GUI cannot be used: Not enabled at compile time
Is there any way to install the GUI by itself, or do I need to reinstall vim altogether?
|
You can install apt-get install either vim-gtk or vim-gnome or even vim-lesstif to get a vim gui.
| Install Gvim after vim |
1,298,696,585,000 |
In Linux vim and gvim, I can make a visual selection by pressing V (e.g., v VISUAL or Shift+V VISUAL LINE), releasing it, and using movement keys (e.g., arrows) to highlight the desired text.
In Windows gvim, however, I must hold down Shift while I make my selection. Also, Ctrl+V (block) selection is supplanted by th... |
When gvim starts, it sources a file called mswin.vim via the _vimrc file. In the mswin.vim file the keys are remapped. You can undo this two ways. One is edit the mswin.vim file and remove the mapping (not recommended). A second easier potentially less invasive way is to edit the _vimrc file.
1. Start gvim as Ad... | Vim visual selection method differs between Windows & Linux? |
1,298,696,585,000 |
Is it possible to use gvim --remote-silent and similar as an editor for visudo and sudoedit? Actually, I don't think this is related to the --remote option. Even if I set Defaults editor = "/usr/bin/gvim", the tmpfile gvim loads is blank and editing it has no effect.
|
gvim returns almost immediately. When sudoedit notices that the editor has returned it will finish reporting no changes. To get sudoedit to work correctly you need to get it to wait until you are finished editing. I normally use -f switch to do this. I have not tried it but the manual seems to support the use of --rem... | visudo/sudoedit and gvim --remote-silent |
1,298,696,585,000 |
As a user, I want to edit my crontab.
crontab -e
gvim is launched. It prints
"/tmp/crontab.IUVYhK/crontab" [New DIRECTORY]
I can write but as soon as I try to write the temporary file, I get this error message:
"crontab.IUVYhK/crontab" E212: Can't open file for writing
However, I have no issue when using vi as edi... |
You must use a synchronous editor for crontab -e, i.e. one where the command doesn't return until the editing is complete. For example,
export EDITOR="gvim --nofork"
crontab -e
An alternative is this,
crontab -l > ~/.crontab
gvim ~/.crontab
# wait until editing is finished
crontab ~/.crontab
| `crontab -e: E212: Can't open file for writing` when using gvim (works with vi) |
1,298,696,585,000 |
I have key mapping in my ~/.vimrc file that re-indents edited source code on the fly. It looks like as follows:
" press F4 to fix indentation in whole file; overwrites marker 'q' position
noremap <F4> mqggVG=`qzz
inoremap <F4> <Esc>mqggVG=`qzza
Short explanation:
mq place marker 'q' at cursor position
ggVG se... |
You can use the last jump mark (m') as a temporary mark. To avoid using a different command to re-enter insert mode (i vs. a), you can use the gi command, which re-enters insert mode at the position where it was last exited:
inoremap <F4> <Esc>m'ggVG=``zzgi
| Keymaping for re-indent source code in Vim |
1,298,696,585,000 |
When I open a file with gvim with the following command line option,
gvim file +5
I would like the current line (the 5th line) be scrolled to the center of gVIM's window,
Is that possible?
--=--=----=--=----=--=----=--=--
| |
| |
| |
| ... |
You can use
gvim file +5 -c "normal zz"
The -c option allows you to specify an editor command to run when starting vim. zz, as others have mentioned, centers the screen on the cursor line.
| Make gvim scroll to the center after opening a file with line numbers? |
1,298,696,585,000 |
I use vim.gtk3 . to navigate current directory in Netrw Directory Listing view.
I know I can press x to act like xdg-open. I also know I can press - to navigate to parent directory.
But if I press Enter on mp4 binary file, it will show in binary view:
Or if I press Enter on a C text file, it will show in normal cod... |
According to the vim wiki you should be able to do it with Ctrl+^ however it doesn't work on my system, it will only alternate between files. You can pull up a fresh explorer via :Explore or :e .
| How to navigate back from text/binary file view in Vim's Netrw directory listing? |
1,298,696,585,000 |
I am currently using gVim as editor and cannot think about going back to mode-less editing. I code in Java for Android and in Python for another project.
While trying to set up gVim as my primary Python IDE, I have jumped through hoops looking for and installing plugins but its still not as good as when I use IntelliJ... |
Vim can get close(r) to an IDE in terms of features via various plugins, but it will always remain a powerful text editor with great extension capabilities. So for anything larger than a hobby project, you'll certainly miss IDE features like debugging, variable inspection, refactoring, find usages, etc.
But why not ha... | Vim emulation in IDEs vs gVim as IDE |
1,298,696,585,000 |
I recently had to change my Linux work environment from a personal Ubuntu system (having full admin rights) to a corporate Red Hat system (having very limited control on the system). Both running GNOME.
Many things seem to work differently. Above all is the gVim behaviour. I have Vim installed on two Linux machines an... |
Sounds like your Vim is in vi-compatible mode; :set compatible? will print compatible then.
You need to create a ~/.vimrc file (empty one will suffice) to switch Vim to nocompatible mode. In general, it's recommended to put your customizations there, and leave .gvimrc for the very few GUI-only settings.
| Changing gVim behaviour on Red Hat |
1,298,696,585,000 |
I'm still learning C++, but I know already some stuff. I used to use Visual Studio, but after I switched to Debian, I was working with Code Blocks.
Recently I heard about using VIM as IDE and started using it. Problem that appeared is autocompletion is not working. I don't know why, but recently C-P/C-N stopped workin... |
install vim 7.4 on Debian without removing half of the system
Installing from source is a good choice. Compiling vim is not difficult at all. You can read more details and instructions here.
make YouCompleteMe work
Installing YouCompleteMe need some things more difficult but it's good documentation at YouCompleteM... | VIM as c++ IDE - autocomplete |
1,298,696,585,000 |
Is there a way to use vim/gvim as an editor for thunderbird? There was an add-on for it but it is now very out of date.
|
You could look into the Teledactyl add-on for Thunderbird from 5digits.org. They produce a Pentadactyl add-on for firefox which works nicely for controls, although text boxes are admittedly un-vim-ish.
Feature-list says it supports external editors, so gvim could be in your future.
| Using vim/gvim as editor for Thunderbird |
1,298,696,585,000 |
How to install gvim on a RHEL server that doesn't have it (for use with SSH with X11 forwarding*)? No sudo access is available, so it has to be in the user's home directory.
*Getting all the convenience of having the remote Vim in a window that's separate from the shell.
|
It isn't very difficult to install vim in your home directory, and I see that you've found a way. However this is not necessarily the best solution.
Running vim on the remote machine has the downsides of running a remote editor: it lags if the connection lags; it dies if the connection dies.
You can use (g)vim locally... | gvim on RHEL (Red Hat Enterprise Linux) install in home directory |
1,298,696,585,000 |
I use rbenv to manage ruby versions.
I want to install gvim on my ArchLinux and one of it's dependency is ruby.
I'm already use rbenv to install the version 2.0.0-p247 of ruby as root user and set rbenv global 2.0.0-p247,but when I try sudo pacman -S gvim, pacman still install the package ruby-2.0.0_p247-1.... |
You cannot. However, you can trick pacman into thinking you have (there are two ways to do this).
Simply pass the --dbonly option:
pacman -S --dbonly ruby
This will commit the transaction to the database (make a record of the install), but not actually download or install any packages.
If you want, you could also pa... | How to let pacman notice the ruby installed by rbenv? |
1,298,696,585,000 |
I'm on RedHat enteprise at my workstation where both vim and gvim is installed.
when runnint vim --version it's clear that i lack a lot of cool stuff (like clipboard capabilities)
When running gvim --version it's clear that my gvim version is fully decked out.
I'd like to run vim in the terminal, but I'd also like to ... |
You can run gvim in TUI mode by passing -v, but note that you won't have the X clipboard registers unless you're running it under X.
| Run gvim in terminal |
1,298,696,585,000 |
Gvim is set to 78, can't change default text width to "0" at gvim, i edited "C:\Program Files (x86)\Vim_vimrc" set textwidth=0 or set tw=0 but neither helped. How do i disable textwidth parameter?
|
It depends on how you are testing the feature. According to the documentation,
textwidth 'tw' number (default 0)
local to buffer
{not in Vi}
Maximum width of text that is being inserted. A longer line will be
broken after white space to get this width. A zero value disables
... | Can't change default text width in GVim |
1,298,696,585,000 |
I am working on RedHat RHEL5. I want to change the font in GVIM.
The only font format that my GVIM accepts is
*-courier-medium-r-normal-*-*-140-*-*-m-*-*
It refuses to use Courier\ New or Courier_New names.
The default font is ugly and I wanted to change it to something prettier, like monospace font that I use in my... |
Take a look at this tutorial that shows how to install a custom font in your home directory, in a .fonts directory. The tutorial is titled: installing fonts in your home directory on Fedora 12.
Once a custom font has been installed here you can use the pull downs in gvim to change the font or run the command:
:set gu... | Setting programming font in RHEL 5 + gvim |
1,298,696,585,000 |
I want to set up vim so that it opens automatically in tab and not in buffers. I know that I could use alias gvim='gvim -p' or some such shell mapping but I am wondering if there is a way to do that from vim itself.
So, what I want is for
gvim ook eek monkey
to be equivalent in behaviour to
gvim -p ook eek monkey
... |
See :tabnew and :tabedit in :help tabpage. (I'm not sure if you can (or want to) re-map :edit)
(Edit There is a related and helpful SO discussion)
(Edit to match your refined question)
I doubt it will be less hassle than alias gvim=gvim -p, but using autocmd (and some Vimscript, everything in your .vimrc) this might b... | File open in tabs automatically |
1,298,696,585,000 |
Any chance to get (g)vim displaying NerdTree and tagbar above each other left to edited file?
+-----------+-------------+
| nerd tree | edited file |
| contents | |
+-----------+ |
| tagbar | |
| contents | |
+-----------+-------------+
I'd like to have it done in ... |
That will be difficult. Both :NERDTreeToggle and :TagbarToggle use :vsplit internally, and there's no way to simply reconfigure or hook into it.
You'd have to write wrappers for your \e and <F9> triggers that detect the current window layout, do the toggling, and then jiggle the windows around to fit your requirements... | (g)vim - NerdTree and tagbar above each other left to edited file? |
1,298,696,585,000 |
Please, consider a situation, where you find a nice example and want to copy it to your existing code to see, how it works.
The indentation is almost never right right away. If there are several lines, line-by-line editing can be tedious. On another question, there were hints on how to add spaces into a block of line... |
After pasting, you can do:
'[>']
To shift the just-inserted text by 'shiftwidth' columns. You can repeat with ..
| Pasting with spaces added into heads of lines (analogy to comment-chars)? |
1,298,696,585,000 |
I installed vim-powerline and was wondering how to change the backlground colour of the normal mode -- currently set to #adf000 according to the Gimp -- to something else. I assume that the change will be in autoload/Powerline/Colorschemes/XXX.vim somewhere, I just cannot find it.
|
The colours of vim-powerline should be located in your .vim directory. If you use a plugin manager it may be .vim/bundle/ followed by the vim-powerline/autoload/Powerline/Colorschemes tree. The file you are looking for should be the default.vim.
The colour setting you are looking for is :
. \ Pl#Hi#Segments(['mode_... | Vim powerline plugin colour of Normal mode |
1,298,696,585,000 |
When I switch from gvim to another application and then after some time switch back gvim window appears blank with cursor blinking in the middle. Sometimes toolbar and tabs look like a white space.
When I opening a new tab, tab bar doesn't refresh itself and shows the same tabs as before opening new tab. When I resizi... |
you could try something like:
:au FocusGained * :redraw!<CR>
| Gtk application (Gvim) rendering troubleshooting |
1,298,696,585,000 |
By convention, our C++ headers live in .hpp files. When I open a gvim window with a .cpp file (so C++ source), then use the open menus, I get file chooser window which allows me to select files for:
C++ Source Files (*.cpp, *.c++)
C Header Files (*.h)
C Source Files (*.c)
All Files (*.*)
Clearly, none of those will ... |
This can be configured via a buffer-local b:browsefilter variable, which is set in filetype plugins; for C/C++, $VIMRUNTIME/ftplugin/c.vim. To change / override this, just put the following into ~/.vim/after/ftplugin/cpp.vim:
let b:browsefilter = "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" .
\ "C Header Files (*... | C++ header/source files in file chooser |
1,298,696,585,000 |
How to add 4 spaces to every line between marks (bound with m-letter and current line). How to do the same when using visual block?
|
:'x,.s/$/ /
Would add 4 spaces at the end of the lines between mark x and the current line.
In visual mode, you can press : which will bring :'<,'> and then add s/$/ / to add 4 spaces to the end of each line in that selection.
If you want to add 4 spaces at the right edge of the currently selected visual block,... | Applying a change to every line? |
1,298,696,585,000 |
In a particular perl script and I have a copy of the same but with the changes made in it i want to see both the scripts in such a way that changes made in the copy to be highlighted in a split gvim editor,so that I can compare both simultaneously.What should i do for that?. I know to split gvim but I don.t know how ... |
I think the tool you may be looking for is vimdiff
vimdiff file.copy file.original
| how to see the changes made in a big perl script having the copy of original that is to compare both in a splitted gvim editor simultaneously |
1,300,461,063,000 |
What's the best way to find a laptop with hardware that is amenable to installing and running GNU/Linux? I'm looking for something that will ideally work with GPL'd drivers and/or firmware.
I took a quick look at linux-on-laptops.com, but they don't list some of the newer models for Lenovo, for example. Most of the te... |
Gluglug and other RYF vendors sell laptops running LibreBoot, a free software, microcode-free bios replacement. LibreBoot supports hardware on which it is possible to remove the Intel Management Engine, a small proprietary operating system on modern Intel machines that has been the attack vector of major security expl... | Ideal Hardware for GNU/Linux Laptop |
1,300,461,063,000 |
I'm looking for a new work laptop for development work on linux, and after testing way too many distros, I pretty much does not want to ever use anything other than Xubuntu or possibly some other Debian/Ubuntu based Xfce setup.
What worries me is that most of the recent laptops with Haswell processors I have looked at... |
XFCE has some support for HiDPI - you can change the setting across all monitors for HiDPI, but it doesn't vary between different screens in the way that it does on a Retina MacBook Pro.
I'm using XFCE and Arch Linux on a Lenovo W540 with the high DPI display. Apart from Chrome not supporting HiDPI, things work well.... | What is the status of HiDPI support in Xfce? |
1,300,461,063,000 |
I have a PC Oscilloscope Instrustar ISDS205X which I used on Windows 10. Now that I have switched to Linux, I am unable to find the respective drivers for it. I have tried installing it on PlayOnLinux but the software doesn't install and so do its drivers.
Is there any method to convert such Windows drivers to run on ... |
In short: no.
To go further, a driver is a piece of software that interact with the kernel of the operating system.
When you're working in kernel world, interoperability doesn't exist. POSIX neither.
Everything is totally OS-specific: the architecture, the sub-systems and the way they have been built and designed, th... | Installing Proprietary Windows Drivers on Linux |
1,300,461,063,000 |
As you could notice from the topic it needs to be able get cpu's stepping code properly. As Wikipedia says there're stepping codes like A0, A2, B0 etc. So, commands in linux (ubuntu 16.04) give:
# dmidecode -t 4 | grep Stepping | awk '{ printf $8": "$9"\n" }'
# Stepping: 2
# lscpu | grep Stepping
# Stepping: 2
# cpu... |
There’s no way to map stepping numbers to stepping names using only information from the CPU. You need to look at specification updates from Intel; these contain descriptions of the errata fixed in various revisions of CPUs, and also contain identification information allowing the various steppings to be identified (w... | Get CPU stepping in Linux |
1,300,461,063,000 |
Currently, a causal browse through a number of Linux distros show spotty Poulsbo drivers at best. Has any headway been made recently towards either convincing Intel to coax the driver source out of PowerVR or an acceptable (I can install it without low frame rates, involved steps and without fear that a kernel update ... |
There are open-source gma500 drivers in kernel-3.2 by Alan Cox from Intel. They are lacking 2d/3d/video acceleration but hardware should intialize properly. Not sure you'll find it user-friendly, but it is at least "hacker-friendly" - i.e. allowing to hack-in the missing features (acceleration).
| What is the state of open-source Poulsbo/GMA 500 drivers? |
1,300,461,063,000 |
What are good external tablet input devices for Linux?
It should be used for more convenient use of Inkscape and Gimp.
Some characteristics that are useful, I guess:
connected via USB
included pen with some buttons
tablet should only be sensitive to pen touches
Open-source drivers (a must)
some OS engagement by the v... |
I and friends of mine made some good experiences with the tablets from Wacom.
The Bamboo series contains different tablets in different pricing categories.
My Bamboo for example is connected via USB, the pen as 2 Buttons, the tablet is only sensitive to the pen, has some more buttons and works with my linux out of the... | External tablet input devices for Linux (Inkscape/Gimp)? |
1,300,461,063,000 |
I'm holding out for the ThinkPad Helix 2, which has a detachable tablet as a screen. It comes out later this month. I've heard that installing Linux on bleeding edge technology can be problematic due to driver issues, etc.
Would I likely be able to use this computer to its fullest with Ubuntu (or, better yet, some c... |
Graphics Analysis
HD 4K Support in Kernel 3.10 and UP
Device contains Code-Name IVY BRIDGE Intel HD 4K Graphics Chip.
IVY Bridge should fall under the MESA DRI on LKDB.
Support Options: FOSS MESA DRI Driver or Official Intel i965 Driver.
Wireless Analysis
MBM Ericson Chipset Support
Unsure if this is within the LKD... | Does Linux support the ThinkPad Helix 2? |
1,300,461,063,000 |
There are lots of Linux distributions and every one of them is made according to maintainers point of view using different DE, package managers, kernels etc.
When some part of your hardware is failing to work properly reporting a bug on that should be forwarded to distro maintainers or directly to kernel maintainers? ... |
The first stop is your distribution bug tracker, from there on you will be guided to the next step.
It is said that (unless you are able to reproduce the same bug in any distribution or that if you compile from sources and you are able to reproduce it in several systems) you should report downstream (i.e. at your dist... | Where to file a bug? |
1,300,461,063,000 |
I'm checking arch on a virtualbox (running on ubuntu) before I install it on my machine. I have followed the wiki up until the display driver section. lspci gives:
VGA compatible controller: InnoTek
Systemberatung GmbH Virtual Graphics
Adapter
I assume this is some sort of virtualbox compatible layer, is there a... |
No. It is not possible to provide a VirtualBox VM access to the host video card, only the virtual interface you see listed there. In fact, this is true for most hardware including network cards as well. The primary exception to this is some USB devices and storage controllers that can be revealed to the VM if the host... | Finding the right display driver for arch installation on a virtual box on Lenovo edge13'' |
1,300,461,063,000 |
I'm having trouble using my Apple Magic Keyboard (bluetooth wireless with LiIon battery, Lightning port for charging and tethered usage) with Fedora 25 (kernel: 4.8.15-300.fc25.x86_64).
The problem is that when used in wireless mode, the Fn key does not seem to register. I tried xev and the key itself doesn't trigger ... |
Partial answer: Making sense of the HID infrastructure and the HID raw data
(Disclaimer: I've only done all this for USB, but I suppose it will apply in the same or a similar way to Bluetooth).
HID devices can send and receive reports in a well-defined format. The format for a particular device is given by the HID des... | Fn key for Bluetooth Apple Magic Keyboard (2015) |
1,300,461,063,000 |
What video cards for a Desktop computer compatible with Linux can support Dual Monitors?
Our start up needs to use two monitors but our default enviroment needs two monitors, can somebody recommend a cheap Video Card that could help us to use two monitors?
|
It's been years since I last saw a graphics card that wasn't properly supported on Linux, and quite a while since I last saw a single-framebuffer card. The two biggest off-board chipsets, nVidia and AMD (ex ATI) both offer well-supported multi-screen configurations for X11 on Linux (closed-source binary drivers may be... | What video cards for a Desktop computer compatible with Linux can support Dual Monitors? |
1,300,461,063,000 |
I've connected the monitors to the dock, and the monitors detect when they are being connected and disconnected, so there doesn't seem to be any issue with the signal as such. All the other plugs on the dock are also working perfectly (power, Ethernet, USB to keyboard and mouse, USB-C to laptop). Basically everything ... |
What does the lsusb command say about it?
If the output line for the dock includes ID 17e9:600a, then it is this one: a DisplayLink dock.
DisplayLink docks essentially provide an extra USB-connected almost-GPU that needs its own evdi driver module. The driver package also includes firmware that is needed for the USB-G... | DisplayPort monitors via HP USB-C Universal Dock not detected by HP EliteBook 840 G7 |
1,300,461,063,000 |
I've been thinking that I want a mechanical keyboard, currently I'm using a logitech G510 which is perfect with it's 18 programmable keys (I'm using it with this) but I hear a lot of people drooling over mechanical keys, especially programmers, and I do certainly write a lot and on occasion I code too. Not to mention... |
This keyboard doesn't work properly on Linux. The entire keyboard freezes if you press any macro key.
To be more precise, a kernel issue is currently in progress[1], and a userpace driver is available with some limitations[2].
[1] Bug 79251 - Keyboard status indicators not functioning properly.
[2] K70/K95 RGB (Unoff... | Corsair Vengeance K-95 Keyboard & Linux [closed] |
1,300,461,063,000 |
I have a Radeon HD 7790 which apparently won't work as well in Linux (haven't tried it yet).
My idea is to install Windows as the host and do the Linux work in a VM (which involves stuff that needs 3D acceleration). Could this work?
|
Depends on the software you use. Most support some level of 3D now - VMware Workstation and VirtualBox both do to some extent.
as an aside I have a HD7790 at home and it works fine under Ubuntu 13.04. Use either the open source radeon driver OR get the newest from AMD's website though. The one that comes with Ubuntu ... | Will Linux as a guest be able to make use of hardware support of a Windows host? |
1,300,461,063,000 |
My choice of UPS is this -- CyberPower CP900EPFCLCD or APC Smart-UPS 750VA (SMT750I). I intend to connect UPS with USB for data transfer, not Ethernet.
According to UPS HowTo http://tldp.org/HOWTO/html_single/UPS-HOWTO/, the first one is adviced to run with NUT, and the second with Apcupsd.
Are those package equally g... |
I have used NUT with a wide variety of APC UPS models. Support has gotten event better over the years. I would recommend NUT. It works well when supporting a single server single UPS setup and any number of more complicated configurations. I generally recommend NUT whenever I need to monitor a UPS and shutdown app... | How good is the support for NUT-based UPSs against APC? |
1,300,461,063,000 |
I am using Linux (I have not tried the following on Windows).
I live in Europe. I have a zone 1 DVD that I can read with VLC and a DVD reader connected to the SATA port of an old computer. Problem: when the DVD reader is used outside this computer (using a SATA/USB converter) it is no more able to read the zone 1 DVD!... |
In the beginning, the first computer DVD drives were so-called "RPC I" drives, which would let the CPU deal with large parts of the "regionalization stuff". This turned out to be easy to circumvent, so for quite a while any computer DVD drives on the market have all been "RPC II" drives, which will indeed handle the "... | DVD reader able to read a zone 1 DVD only internally |
1,300,461,063,000 |
I have heard it said before that Ubuntu has the best hardware support of any Linux distro, but I'm confused how that could be the case. Don't the drivers go into the kernel, which means the only thing that should matter for hardware support is what kernel version you're using? I know the non-sourced drivers are strip... |
Short answer: Yes, but I'm lying.
Long answer: ultimately what you need to support some hardware is driver. Some drivers aren't open source, which makes it harder for them to be fixed, updated and adapted to changes.
Some drivers are also compiled in kernel, so you might need to recompile your kernel if you wish to us... | Do Linux distros have different levels of hardware support? [closed] |
1,300,461,063,000 |
Note: I thought about it and really felt like it belongs here. It's not about hardware, such as it is about Linux drivers/compatibility. Am I wrong?
I'm not new to Linux - but I mostly administered VMs here and then.
While considering which board to buy for my new PC (, and while thinking of Microsoft's announce about... |
I thought about it and really felt like it belongs here. It's not about hardware, such as it is about Linux drivers/compatibility. Am I wrong?
no I think you are 100% correct
Did anybody had an experience with one of these motherboards?
with one of those boards specifically - no. But my asrock z97 board on home p... | Hardware ( motherboards, specifically ) compatibility with Linux |
1,300,461,063,000 |
My graphic card is not recognized on my laptop with Debian Jessie installed and a Nvidia Geforce GTX 850M.
glewinfo tells me it uses Mesa DRI with Intel (OpenGL 3.0) instead of Nouveau with the actual GPU (OpenGL 4.4+).
nvidia-detect can't find my graphic card.
lspci identifies my graphic card as a 3d controller wh... |
The poster has a Nvidia Optimus laptop. It turns out, per the Bumblebee page on the Debian Wiki, that you need to do:
apt-get install bumblebee-nvidia primus
and remove any existing xorg.conf and prevent debconf from creating a xorg.conf during the installation of the packages above.
@Spiralwise confirmed that this w... | My graphic card is not recognized on laptop/debian |
1,300,461,063,000 |
Do Ryzen 3 2200u laptops work without issues with stock install of Debian 9 or Ubuntu 18.04?
I do not want to install nor patch nor compile!
I have to choose between Core i3 6006u and Ryzen 3 2200u. I know that Intel SoCs work out of the box on Linux. So they seem like a safe choice.
Any experiences? Does anyone of yo... |
I don't know if this helps you, but I have tried Debian(Kali-rolling) on a Tower with Ryzen3 2200. it worked without problems.
| Ryzen 3 2200u laptop linux compatibility |
1,300,461,063,000 |
If I install Linux on a USB stick using computer A, then plug it into computer B with different hardware and try to boot and work on it, should I generally expect it to work? Or should I rather accept that Linux, when installed (as opposed to using Live CD/USB), gets tied to the hardware and is generally not supposed... |
I've done it; when I got a new laptop about 2 years ago I just pulled out my old hard drive and put it into the new one. A couple months ago I upgraded the OS (Debian stable) and things are still working fine. The only thing I noticed is that instead of eth0 and wlan0 I have eth1 and wlan1.
Generally, Linux installati... | How tied are Linux installations to hardware? [duplicate] |
1,300,461,063,000 |
I took out a my Intel dual band Wireless AC 7260 card model number 7260HMW from another laptop. I wanted to install it in my thinkpad. Upon doing so and rebooting, the computer said unauthorized wifi card and I need to remove it. I read that Lenovo does this to force the use of IBM wifi cards. I am currently running U... |
Not unless you're willing to replace the BIOS. IBMs are usually considered "corporate" machines and this restriction is a "feature" so that you as a user can not install an unsecured or untested Wi-Fi card and bring down your corporate network.
Even in the "home" space, it is still considered a "security feature". Thi... | Installing an unauthorized wifi card in a Lenovo thinkpad edge 14 |
1,300,461,063,000 |
I'm looking for a new desktop (tower) system to run Debian 11. I'd like to avoid having to download proprietary drivers for the hardware to work properly.
Requirements:
Reasonably recent CPU (Intel i7 or better equivalent)
16GB of RAM (upgradeable)
Two screens with resolutions higher than 1920x1080
Especially with p... |
After reading the Phoronix article Intel Arc Graphics Running On Fully Open-Source Linux Driver, I decided for a system based around the following hardware:
INTEL ARC A750 GRAPHICS CARD, 8GB GDDR6
Intel Core i7 13700KF CPU
MSI PRO B760M-P DDR4 mATX Motherboard
Here is my experience:
Debian 11 (bullseye):
Booting t... | Hardware recommendations for new Debian 11 desktop: Mostly free graphics drivers? |
1,346,971,085,000 |
Say I have a huge text file (>2GB) and I just want to cat the lines X to Y (e.g. 57890000 to 57890010).
From what I understand I can do this by piping head into tail or viceversa, i.e.
head -A /path/to/file | tail -B
or alternatively
tail -C /path/to/file | head -D
where A,B,C and D can be computed from the number ... |
I suggest the sed solution, but for the sake of completeness,
awk 'NR >= 57890000 && NR <= 57890010' /path/to/file
To cut out after the last line:
awk 'NR < 57890000 { next } { print } NR == 57890010 { exit }' /path/to/file
Speed test (here on macOS, YMMV on other systems):
100,000,000-line file generated by seq... | cat line X to line Y on a huge file |
1,346,971,085,000 |
Is there a way to head/tail a document and get the reverse output; because you don't know how many lines there are in a document?
I.e. I just want to get everything but the first 2 lines of foo.txt to append to another document.
|
You can use this to strip the first two lines:
tail -n +3 foo.txt
and this to strip the last two lines, if your implementation of head supports it:
head -n -2 foo.txt
(assuming the file ends with \n for the latter)
Just like for the standard usage of tail and head these operations are not destructive. Use >out.txt ... | How to obtain inverse behavior for `tail` and `head`? |
1,346,971,085,000 |
I have a file with many rows, and each row has a timestamp at the starting, like
[Thread-3] (21/09/12 06:17:38:672) logged message from code.....
So, I frequently check 2 things from this log file.
First few rows, that has the global conditions and start time is also given.
Last few rows, that has the exit status wi... |
You can use sed or awk to make it with one command. However you'll loose at speed, cause sed and awk will need to run through the whole file anyway.
From a speed point of view it's much better to make a function or every time to combination of tail + head. This does have the downside of not working if the input is a p... | Command to display first few and last few lines of a file |
1,346,971,085,000 |
Variants of this question have certainly been asked several times in different places, but I am trying to remove the last M lines from a file without luck.
The second most voted answer in this question recommends doing the following to get rid of the last line in a file:
head -n -1 foo.txt > temp.txt
However, when I... |
You can remove the first 12 lines with:
tail -n +13
(That means print from the 13th line.)
Some implementations of head like GNU head support:
head -n -12
but that's not standard.
tail -r file | tail -n +13 | tail -r
would work on those systems that have tail -r (see also GNU tac) but is sub-optimal.
Where n is 1:
... | Negative arguments to head / tail |
1,346,971,085,000 |
find command can output names of files as a null-delimited strings (if -print0 is provided), and xargs can consume them with -0 option turned on. But in between, it's hard to manipulate that collection of files - sort command has -z switch, that makes it possible to sort those files, but head and tail don't have them.... |
GNU head and tail since coreutils version 8.25 have a -z option for that.
With older versions or for non-GNU systems, you can try and swap \0 and \n:
find ... -print0 |
tr '\0\n' '\n\0' |
head |
tr '\0\n' '\n\0'
Note that some head implementations can't cope with NUL characters (and they're not required to by P... | How to do `head` and `tail` on null-delimited input in bash? |
1,346,971,085,000 |
The following shell command was expected to print only odd lines of the input stream:
echo -e "aaa\nbbb\nccc\nddd\n" | (while true; do head -n 1; head -n 1 >/dev/null; done)
But instead it just prints the first line: aaa.
The same doesn't happen when it is used with -c (--bytes) option:
echo 12345678901234567890 | (w... |
Is it correct for the head utility to consume more characters from the input stream than it was asked?
Yes, it’s allowed (see below).
Is there some kind of standard for Unix utilities?
Yes, POSIX volume 3, Shell & Utilities.
And if there is, does it specify this behavior?
It does, in its introduction:
When a st... | head eats extra characters |
1,346,971,085,000 |
Background
I am running an SSH server and have this user that I want to delete. I cannot delete this user because he is currently running a few processes that I need to kill first.
This is the pipeline I am using currently using to find out all the process ids of the user I am currently using:
ps -u user | awk '{print... |
NOTE: if your system already has pgrep/pkill then you are re-inventing the wheel here. If your system doesn't have these utilities, then you should be able to format the output of ps to get the unencumbered PID list directly e.g. ps -u user -opid=
If you are already using awk, there is no need to pipe through an addit... | Command to remove the first N number of lines in input |
1,346,971,085,000 |
I need a utility that will print the first n lines, but then continue to run, sucking up the rest of the lines, but not printing them. I use it to not overwhelm the terminal with the output of a process that needs to continue to run (it writes results to a file).
I figured I can do process | {head -n 100; cat > /dev/n... |
To continue "sucking up" the output from process while only printing the first 100 (or whatever) lines:
process | awk 'NR<=100'
Or:
process | sed -n '1,100p'
| Alternative to 'head' that doesn't exit? |
1,346,971,085,000 |
Given the following 3 scripts:
printf 'a\nb\nc\n' > file && { head -n 1; cat; } < file
printf 'a\nb\nc\n' | { head -n 1; cat; }
{ head -n 1; cat; } < <(printf 'a\nb\nc\n')
I'd expect the output from each to be:
a
b
c
but for some of those, on some systems, that is not the case. For example, on cygwin:
$ printf 'a\n... |
head may read its whole input. It must read at least what it outputs (otherwise it is logically impossible to implement), but it may read more.
Typically head asks the operating system to read a fixed-size buffer (by calling the read system call or similar). It then looks for newline characters in that buffer, and pri... | Can `head` read/consume more input lines than it outputs? |
1,346,971,085,000 |
Just hit this problem, and learned a lot from the chosen answer: Create random data with dd and get "partial read warning". Is the data after the warning now really random?
Unfortunately the suggested solution head -c is not portable.
For folks who insist that dd is the answer, please carefully read the linked answer ... |
Unfortunately, to manipulate the content of a binary file, dd is pretty much the only tool in POSIX. Although most modern implementations of text processing tools (cat, sed, awk, …) can manipulate binary files, this is not required by POSIX: some older implementations do choke on null bytes, input not terminated by a ... | What's the POSIX way to read an exact number of bytes from a file? |
1,346,971,085,000 |
Possible Duplicate:
IO redirection and the head command
I just wanted to remove all but the first line of a file. I did this:
head -1 foo.txt
... and verified that I saw only the first line. Then I did:
head -1 foo.txt > foo.txt
But instead of containing only the first line, foo.txt was now empty.
Turns out that... |
Before the shell starts processing any data, it needs to make sure all the input and output is squared away.
So in your case using > foo.txt basically tells the system: "create a (new) file named foo.txt and stick all the output from this command into that file".
The problem is, as you found out, that that wipes out ... | Why does `cat`ing a file into itself erase it? [duplicate] |
1,346,971,085,000 |
I can do diff filea fileb to see the difference between files. I can also do head -1 filea to see the first line of filea or fileb. How can I combine these commands to show the difference between the first line of filea and the first line of fileb?
|
If your shell supports process substitution, try:
diff <(head -n 1 filea) <(head -n 1 fileb)
| Compare the heads of two files in bash |
1,346,971,085,000 |
The following commands seem to be roughly equivalent:
read varname
varname=$(head -1)
varname=$(sed 1q)
One difference is that read is a shell builtin while head and sed aren't.
Besides that, is there any difference in behavior between the three?
My motivation is to better understand the nuances of the shell and key ... |
Neither efficiency nor builtinness is the biggest difference. All of them will return different output for certain input.
head -n1 will provide a trailing newline only if the input has one.
sed 1q will always provide a trailing newline, but otherwise preserve the input.
read will never provide a trailing newline, and... | Is there a difference between read, head -1, and sed 1q? |
1,346,971,085,000 |
I'm currently using
watch head -n 17 *
which works, but also shows all lines up to the 17th. Basically, I would like to only show the last line for each file that is shown with my current approach. How can I achieve that?
Example
For the sake of example, let's reduce the line nr. to 7. So:
Example file:
1
2
3
4
5
6
7... |
With GNU awk:
watch -x gawk '
FNR == 17 {nextfile}
ENDFILE {if (FNR) printf "%15s[%02d] %s\n", FILENAME, FNR, $0}' ./*
Which gives an output like:
./file1[17] line17
./short-file2[05] line 5 is the last
Note that the ./* glob is expanded only once at the time watch is invoked.
Your watch head -n 17 *... | How can I watch the 17th (or last, if less) line in files of a folder? |
1,346,971,085,000 |
I have a directory with ~1M files and need to search for particular patterns. I know how to do it for all the files:
find /path/ -exec grep -H -m 1 'pattern' \{\} \;
The full output is not desired (too slow). Several first hits are OK, so I tried to limit number of the lines:
find /path/ -exec grep -H -m 1 'pattern' ... |
Since you're already using GNU extensions (-quit, -H, -m1), you might as well use GNU grep's -r option, together with --line-buffered so it outputs the matches as soon as they are found, so it's more likely to be killed of a SIGPIPE as soon as it writes the 6th line:
grep -rHm1 --line-buffered pattern /path | head -n ... | limit find output AND avoid signal 13 |
1,346,971,085,000 |
head -num is the same as head -n num instead of head -n -num (where num is any number)
Example:
$ echo -e 'a\nb\nc\nd'|head -1
a
$ echo -e 'a\nb\nc\nd'|head -n 1
a
$ echo -e 'a\nb\nc\nd'|head -n -1
a
b
c
This head -1 doesn't seem to be documented anywhere.
$ head --help
Usage: head [OPTION]... [FILE]...
Print th... |
The info page and the online manual for GNU head contain this part:
For compatibility head also supports an obsolete option syntax
-[NUM][bkm][cqv], which is recognized only if it is specified first.
The idea that head -1 is the same as head -n 1 is that the dash is not a minus sign, but a marker for a command lin... | Why isn't "head -1" equivalent with "head -n -1" but instead it's the same as "head -n 1"? |
1,346,971,085,000 |
I've got 'color cat' working nicely, thanks to others
(see How can i colorize cat output including unknown filetypes in b&w?).
In my .bashrc:
cdc() {
for fn in "$@"; do
source-highlight --out-format=esc -o STDOUT -i $fn 2>/dev/null || /bin/cat $fn;
done
}
alias cat='cdc' # To be next to the cdc definition above.... |
Something like this should do what you want:
for cmd in cat head tail; do
cmdLoc=$(type $cmd | awk '{print $3}')
eval "
$cmd() {
for fn in \"\$@\"; do
source-highlight --failsafe --out-format=esc -o STDOUT -i \"\$fn\" |
$cmdLoc -
done
}
"
done
You can condense it lik... | How can I colorize head, tail and less, same as I've done with cat? |
1,346,971,085,000 |
Say I only need the first 5 lines of an output for logging purposes. I also need to know if and when the log has been truncated.
I am trying to use head to do the job, the seq command below outputs 20 lines that get truncated by head, and I echo a truncating information:
> seq -f 'log line %.0f' 20 | head -n 5 && ech... |
A note of warning:
When you do:
cmd | head
and if the output is truncated, that could cause cmd to be killed by a SIGPIPE, if it writes more lines after head has exited. If it's not what you want, if you want cmd to keep running afterwards, even if its output is discarded, you'd need to read but discard the remaining... | Truncate output after X lines and print message if and only if output was truncated |
1,346,971,085,000 |
If I do a
svn log | head
after the tenth line of output I get an error message:
svn: Write error: Broken pipe
What's going on here? I haven't seen any other command do this when used with head. Is Subversion unfriendly to the Unix filtering paradigm?
|
When you write to a pipe whose other end has been closed, you normally receive a SIGPIPE signal and die. However, if you choose to ignore that signal, as svn does, then instead the write returns with -1 and errno set to EPIPE whose English translation is "Broken pipe". And svn chooses to display that error message whe... | Why does Subversion give a broken pipe error when piped into head? |
1,346,971,085,000 |
I'm helping the netadmin here with a perl regex to automate operating on some snapshots from our SAN and our scripts does stuff like this:
varinit1=$(iscsiadm -m session | grep rbmsdata1 | head -n1 | perl -pe 's/^tcp: \[\d*\] \d*\.\d*\.\d*\.\d*:\d*,\d* (iqn\..*\..*\..*:.*-.*-.*-.*-(.*-.*-\d{4}-\d{2}-\d{2}-\d{2}:\d{2}:... |
While your question maybe contains an error (long utf8 dash instead of the normal one):
$ head –n1
head: cannot open ‘–n1’ for reading: No such file or directory
$ head -n1 # ctrl-d
$
I will supposed that was just a browser thing, since only one occurence was like that. head waits for input when it needs it anyway. ... | Peculiar piping grep/head behavior |
1,346,971,085,000 |
I'm using the ubuntu terminal, I need to move a specific line in a file ( 11th position ) to the first line and then transfer the final result into a new file. The original file contains hundreds of lines.
So far I tried to use the sed command tool, but I'm not achieving what I want. This is what I got so far :
[missi... |
sed -n '1h;2,10H;11G;11,$p'
First line, copy h because of new line, then append H until 10.
At line 11, get the hold space
From 11 to end, print.
]# sed -n '1h;2,10H;11G;11,$p' bonj
French: Bonjour
English: Hello
Turkish: Marhaba
Italian: Ciao
German: Hallo
Spanish: Hola
Latin: Salve
Greek: chai-ray
Welsh... | Move specific line from a position to another |
1,346,971,085,000 |
For example, we have N files (file1, file2, file3 ...)
We need first 20% of them, the result directory should be like (file1_20, file2_20, file3_20 ...).
I was thinking use wc to get the lines of the file, then times 0.2
Then use head to get 20% and then redirect to a new file, but i don't know how to automate it.
|
So creating a single example to work from:
root@crunchbang-ibm3:~# echo {0..100} > file1
root@crunchbang-ibm3:~# cat file1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64... | Copy a specific percentage of each file in a directory to a new file |
1,346,971,085,000 |
There are lots of txt files in a directory.
If I do time wc -l *.txt | head it takes
real 0m0.032s
user 0m0.020s
sys 0m0.008s
If I do time wc -l *.txt | tail it takes
real 0m0.156s
user 0m0.076s
sys 0m0.088s
Does this mean that wc will know beforehand that it is piping to head and will only cou... |
I did a strace on both commands. The interessting thing is that when you pipe the output to head there are only 123 system calls. On the other hand when pipeing to tail there are 245 system calls (or more when there are more *.txt files).
Case: head
Here are the last few lines when pipeing to head:
open("file12.txt",... | Time required to do pipe output to head/tail [duplicate] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.