New answers tagged

2 votes

awk how to set the format output filename for multiple output

{x=++i} would result in 2 variables, x and i, which both have the same value as the builtin variable NR (and FNR). print $2 > "HG"x".txt" is undefined behavior due to no parens ...
user avatar
  • 21.9k
-2 votes

Replace dots with underscores in filenames, leaving extension intact

@echo off for /f "delims=" %%a in ('dir /b *') do call :dot "%%a" pause goto :EOF :dot set "var=%~n1" set "var=%var:.= %" ren %1 "%var%%~x1" @echo ...
user avatar
1 vote

How to get the filenames and their absolute paths in one line?

Hi and thanks for mentioning fselect! The problem with odd filenames is not new obviously. We can't even be sure that the filename and its path will be on the same line in case they contain \n within. ...
user avatar
0 votes

How to get the filenames and their absolute paths in one line?

With zsh: for f (**/*(DN)) print -r -- $f $f:P $f:P does the equivalent of realpath() so expands to the canonical absolute path of the file (expanding all symlinks in the path components to their ...
user avatar
1 vote

How to get the filenames and their absolute paths in one line?

I would like to mention fselect which is written in Rust and uses a SQL(ish) syntax which I can remember a bit more easily: fselect name, abspath from . For illustrating the relevant issue with ...
user avatar
  • 111
0 votes

recursive statistics on file types in directory?

Here is an improved version of maxschlepzig's answer: find . -type f -printf "%f\n" | sed 's/.*\(\.\)/\1/' | sort | uniq -c | sort -k 1nr Or if your find doesn't support -printf you can use ...
user avatar
10 votes
Accepted

Handle names with spaces when iterating recursively over files

Your error lies in using find in a command substitution. A command substitution always results in a single string. If you leave the substitution unquoted, that string will undergo splitting on spaces, ...
user avatar
  • 267k
1 vote

looping through filename

Assuming you know that you will always want to use the files in groups of three, that the pattern *.txt matches all relevant files (and no more), and that the files are correctly sorted (as the ones ...
user avatar
  • 267k
2 votes

What are the implications of adding "./" to relative symbolic links?

Creating a symbolic link only stores the target as a string, no attempt is made to resolve the link at all. There are several reasons for this; one is that a symbolic link can be created pointing to a ...
user avatar

Top 50 recent answers are included