Questions tagged [whitespace]

combination of spaces, tabs, or newlines which create "empty" space in a line or column

Filter by
Sorted by
Tagged with
1 vote
1 answer
31 views

How to use unix `mv` to rename files with unicode spaces(not U+20)?

$ ls cn* cn blah blah.txt $ ls cn\ * ls: cannot access 'cn *': No such file or directory $ ls cn*|hexdump -C 00000000 63 6e e2 80 85 62 6c 61 68 c2 a0 62 6c 61 68 2e |cn...blah..blah.| 00000010 74 ...
Remi Arntzen's user avatar
7 votes
4 answers
2k views

Why does a backslash at the end of the line place undue whitespace?

I wanted: #!/bin/bash cmd --options \ option=value,\ option=value,\ option=value,\ option=value But running with bash -x I got: cmd --options option=value, option=value, option=value, ...
rhuanpk's user avatar
  • 385
0 votes
1 answer
31 views

How to make emacs start in bash by visiting a find command result containing whitespace in its name and double quotes in path? [duplicate]

I'm confronted with an escape challenge: The process: Step 1 - the file retrieval: Within bash, find command will be invoked. Find commands output is 1 single file with a path like this: ./vacation/...
user avatar
1 vote
1 answer
48 views

Expand tabs in file with utf8 characters

I use expand to expand tabs to spaces. For utf8 files expand doesn't work correctly. E.g. in ć\ta tab is expanded to 6 spaces while in a\ta to 7 spaces. How do I make it work for utf8 files?
Marcin Król's user avatar
0 votes
3 answers
230 views

Adding 10 whitespace characters using sed

I have written a script that replaces a string, but I need to add the 10 whitespace characters back. I can add it back by pressing space 10 times, and that works, but this looks hideous in my script. ...
user898458's user avatar
0 votes
3 answers
384 views

How can I test if a string has any ASCII white space characters in it?

How can I check if a string has any whitespace characters in it? I do not have to worry about things outside of ASCII for example unicode zero width characters etc. You can assume that the string is ...
Chris Stryczynski's user avatar
0 votes
2 answers
49 views

Shell function to center its first argument

In the nano text editor, I can pipe the selection into a command, and I quite often need to center text, so I came up with the following code center() { str=$1 # Strip leading and trailing ...
user avatar
-1 votes
2 answers
45 views

Unable to remove space for filenames [closed]

I'm unable to remove space from filenames as below, Please advise if any solution is there on this issue. thank you /home/files: Dec 14 22:10 testfiles Dec 15 12:30 test file1 Dec 14 21:45 test ...
kumar's user avatar
  • 1
0 votes
5 answers
185 views

Whitespaces in alias bashrc

I use Bash I wrote a command for printing only docker id separate with whitespaces on one line. docker ps -a | grep -E '^[a-z0-9]{12}' -o | awk '{printf "%s ",$0} END {print ""}' ...
Admineral's user avatar
1 vote
1 answer
73 views

spaces in filenames -- general prevention strategies

Spaces in filenames are a problem which is as known as enervating. Nevertheless, there does not seem to be a big list how to prevent them, nor does prevention seem to be supported by the common static ...
user7427029's user avatar
1 vote
1 answer
637 views

Why does nano indent pasted text or code improperly?

When I copy and paste text from the clipboard, the code looks like [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ...
siralbert's user avatar
0 votes
1 answer
87 views

GNU sed: append both BEFORE name start and AFTER name end (output is: "$ ls -xN")

Please could someone check if my GNU sed script is the nice way to do it or if it's some sort of bad / wrong hack :p $ ls -xN 1 2 3 4 $ ls -xN | sed -E "s/(.{1})$/\1\.log/" | sed -E "s/...
T. Caio's user avatar
  • 129
3 votes
3 answers
1k views

Replacing command line arguments while preserving spaces

I would like to selectively replace a command-line argument that is being passed to automatically format it for the downstream command being executed. The argument will have spaces and that is the ...
Walter's user avatar
  • 1,214
0 votes
2 answers
173 views

detailed bash script with cp and grep will not work with spaces in filenames

I would never do it myself but people with Windows machines insist on putting spaces in filenames. I've composed this detailed command which works perfectly except for the files with spaces in them. ...
cardamom's user avatar
  • 548
1 vote
1 answer
100 views

Strip leading and trailing whitespace when piping to GNU parallel

When I try to write a pipeline like this: git branch | rg '^\*' | parallel git pull {} I run into a problem with whitespace. Because the branch names have leading whitespace, parallel ends up ...
Dommondke's user avatar
  • 133
0 votes
1 answer
964 views

Include spaces and tabs in "awk" search and replace

Another user helped me earlier to fix something I'm doing with awk, where I search for a string at any point in all files and replace two numbers in the same line when I find it. awk -i inplace '/^...
the_pocket_of_big_noob's user avatar
0 votes
2 answers
140 views

grep results with spaces and special chars

I am trying to grab results from lshw and add them to a a bash array so I can create a new string. I am using lshw -class disk |egrep -A 7 .'-d' |grep 'product' |cut -b 17- the output looks like this ...
xtree's user avatar
  • 1
0 votes
1 answer
265 views

tar invalid transform expression error due to whitespaces over ssh call

I am using tar --transform over SSH call to rename the documents during archiving based on array DOCUMENTNAMES. tar -uvf /tmp/$TARGET''TVL_document.tgz'' --transform='s|'\${doc}'|'\$docname'|' -C /...
Adewan09's user avatar
0 votes
0 answers
26 views

Execute command from string containing spaces [duplicate]

How to execute command from string containing spaces? $ ls "xxx yyy" a.exe $ X="./xxx yyy/a.exe" ; $X -bash: ./xxx: No such file or directory $ X='./xxx yyy/a.exe' ; $X -bash: ./...
pmor's user avatar
  • 519
1 vote
1 answer
52 views

How does unexpand command work with more than one tablist?

I tried reading the manual for unexpand as well as read the answer here but I do not understand how unexpand works with a tablist as an argument. When I try the following (2 spaces and 3 spaces ...
kovac's user avatar
  • 111
4 votes
0 answers
906 views

zsh/oh-my-zsh: how to make tab completion add no trailing space for non-folder files?

I installed zsh and oh-my-zsh. By default, when using tab completion zsh adds a trailing space for non-folder files. For demonstration I created the following folders/files in a folder named ...
user3716849's user avatar
0 votes
2 answers
421 views

Grep is not retrieving string with space

I have a series of headings in a file that have names like this: grep ">scaffold_3" DM_v6.1_unanchoredScaffolds.fasta >scaffold_3 >scaffold_303 >scaffold_31 >scaffold_34 >...
Gigiux's user avatar
  • 497
1 vote
2 answers
4k views

sed possible white space match

I have to modify some paramteres in a param file that may look like: MY_VAR=YES I want to use `sed and came up with this: sed -i 's/MY_VAR=[A-Z]*/MY_VAR=NO/' sed.txt whih seems to work, now I also ...
Testix's user avatar
  • 73
0 votes
2 answers
221 views

Pass qouted filename with spaces in a bash variable [duplicate]

In a bash shell, consider this: $ x="-name 'foo bar'" $ find $x find: paths must precede expression: `bar'' $ find -name 'foo bar' ./foo bar What can I put in $x to make find $x behave like ...
oskark's user avatar
  • 21
3 votes
1 answer
110 views

Is there a trick to re-align tabular data in the terminal after filtering with grep?

Good example of what I'm getting at: try doing ss -axl to show listening UNIX domain sockets. For example, this might give: Netid State Recv-Q Send-Q ...
fdmillion's user avatar
  • 2,768
7 votes
4 answers
9k views

Bash for loop with string var containing spaces

In my directory I have two files with space, foo bar and another file. I also have two files without space, file1 and file2. The following script works: for f in foo\ bar another\ file; do file "$...
Pedro Siqueira's user avatar
0 votes
1 answer
43 views

How to differ strings with and without ending/starting spaces? [duplicate]

I need to format a text file (a Fortran source code) and change some keywords from small letters to capitals or vice versa. I've made an array of possible keywords and have the following piece of the ...
Mikhail Modestov's user avatar
1 vote
3 answers
135 views

avoid spaces and apostrophes problems with ls in a awk script [duplicate]

I have many identical files in two (local) devices, and it happens that I have renamed some, only in one device (A). I found the following way to rename the identical files in the other device (B), ...
paco's user avatar
  • 13
0 votes
3 answers
574 views

find results containing space to be printed with enclosing quotes

How can find search results containing spaces to be printed with enclosing '' (a quote pair). Only if this result contains spaces, if there are not spaces in the path string, to remain as is.
user avatar
2 votes
6 answers
5k views

How to count spaces in text?

In the following example, there are 4 spaces before inet. wolf@linux:~$ ip address show eth0 | grep 'inet ' inet 10.10.10.10/24 brd 10.10.10.255 scope global dynamic eth0 wolf@linux:~$ How do I ...
Wolf's user avatar
  • 1,571
3 votes
1 answer
955 views

Can I make shell consider NBSP a whitespace character?

This seems like a common issue: you paste a simple command from somewhere into the terminal and it's not being understood by a shell: $ echo test $ zsh: command not found: echo test The reason is ...
Eugene Yarmash's user avatar
2 votes
3 answers
4k views

Grep Lines from File with spaces

I have File which contains Records qwe.google.com IN A 1.1.1.1 qwe.google.com IN {uneven-space} A{space}1.1.1.1 qwe.google.com IN CNAME asd.google.com I need to grep all the lines which ...
user416391's user avatar
0 votes
1 answer
388 views

need script to rename files replacing double space with single space

Can someone help me figure out how to remove double spaces from directory names? I'm using a service which gives me a directory structure of files whose names contain spaces. Sometimes the directory ...
Jim Newton's user avatar
11 votes
1 answer
1k views

Why does this grep statement do the opposite of what I expect?

I have a file with some HTML and some text mixed in, I just wanted to use the text lines. I was fooling around with grep, trying to get a way to exclude the lines that began with an HTML tag, even ...
Joe Schmoe's user avatar
1 vote
1 answer
69 views

How may I loop through a list that contain whitespaces?

I need to iterate through my list that sometimes contains whitespaces. That is the script that I use right now locate .txt > list for book in $(cat list) do cp "${book}" /mnt/e/BOOK done I, ...
Dmitrii Trubetskoy's user avatar
3 votes
2 answers
772 views

How to replace the leading tab (including tabs after some space characters) only?

I have some files that are indented by tabs or spaces or both. I want to convert leading tabs to spaces (one tab to 4 spaces). This includes tabs after some leading spaces. Below are some examples of ...
Just a learner's user avatar
1 vote
1 answer
350 views

sed bash script is unexpectedly replacing character with space instead of newline [duplicate]

Using bash command syntax: echo "The*quick*brown*fox"|sed s/*/\\n/g I get the desired output: The quick brown fox However in script: IN_TXT="The*quick*brown*fox" OUT_TXT=$(echo $IN_TXT|sed s/*/\\...
SPB's user avatar
  • 13
-1 votes
1 answer
244 views

bash function to handle space(s) from command line argument

Always typing c d.. or c d .. to move up one dir. Placed function below in my .bash_profile, but only the first character before the white space -"c" is being interpreted instead of the entire set ...
jumboshrimps's user avatar
0 votes
2 answers
510 views

For loop with grep and spaces

I seem to have a little bit of an issue with spaces when trying to use for loops and grep together. The whitespace is important because, for example, I'd like to match 'k117_19650 ', but not '...
Laura's user avatar
  • 199
5 votes
1 answer
4k views

Nano - highlight trailing whitespaces

I use nano as my standard editor for a file type it has no build in syntax-highlighting for LilyPond. It is nothing I really need, though I'm missing out quite a lot of white-space characters at the ...
nath's user avatar
  • 5,510
0 votes
3 answers
138 views

Not able to access files copied using double quote

By mistake, I have copied 100 files using the cp command as $ cp file1 "/data/ file1" $ cp file2 "/data/ file2" note:- there is a space between /data and file2, file1 Within the /data directory, I ...
user1726453's user avatar
2 votes
2 answers
982 views

bash scripts: using whitespace

I've tried web search and search on that site but found only problems with usage of whitespace for strings in bash. However I'd like to understand general logic behind usage of whitespace in bash ...
Alex Martian's user avatar
4 votes
2 answers
4k views

exporting variables from environment file with spaces in values [duplicate]

Say I have this .env file: A=1 B=2 C="3 4 5" If I run set -x; echo $(cat .env | xargs): ++ cat .env ++ xargs + echo A=1 B=2 C=3 4 5 A=1 B=2 C=3 4 5 If I run set -x; export $(cat .env | xargs): ++...
Charles Langlois's user avatar
1 vote
2 answers
1k views

Replace characters after match with sed

I have a string: 172.16.1.5] "80 EE 73 2F 0B 40 I need to replace all the spaces after the ] " with a colon. Currently using sed -r 's/[ ]+/:/g' I get an output of 172.16.1.5]:"80:EE:73:2F:0B:40:, ...
john doe's user avatar
  • 776
0 votes
1 answer
1k views

Dealing with spaces in bash when piping the results from one command to another

I need to go recursively through several directories/files, in bash, replacing a certain string with another if it exists in a file. I had this solved in my script with the line: grep -rl "...
Darth Twerk's user avatar
2 votes
1 answer
86 views

SH/BASH: Store Command Parameter with Whitespace in Variable [duplicate]

I'm trying to store a command string in a variable for later execution. The problem is that the command includes a parameter argument with whitespace. When the command is executed, instead of seeing ...
AntumDeluge's user avatar
1 vote
2 answers
1k views

Unwanted trailing white-spaces comes along on copy-paste

I'm using Tmux & Zsh (WSL) and am very frustrated with all the white-spaces that comes with when copy content from a file while using nano. nano .zshrc . When using Shift+Right Mouse Button or ...
Zoric's user avatar
  • 19
3 votes
2 answers
410 views

Remove trailing whitespace in df command

I have the following df command: > df -h --output=used,avail,pcent / Used Avail Use% 5.9G 12G 34% Notice how there is a space before Used and 5.9GB So I did the following: > df -h --...
K Split X's user avatar
  • 1,663
4 votes
1 answer
1k views

Using sed to replace a string where the replacement contains whitespace

I have the need to replace a single line in multiple files and have been playing around with sed for a solution. I am encountering this error: sed: -e expression #1, char 31: unterminated `s' command ...
WonderingSoul's user avatar
1 vote
3 answers
3k views

How to find and replace seemingly a tab char using sed?

I have a line looks like this: some.com *.some.com The space is seemingly a tab space because when I move the keyboard arrow, one move will move me to the end of it (it does not seem multiple ...
user9371654's user avatar