Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [whitespace]

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

1
vote
2answers
51 views

How to sort a file with multiple delimiters?

Listing the available patches in openSUSE results in the following output. The command that results int the details below is zypper patches. The same result is also displayed when running the ...
0
votes
1answer
33 views

automatically repair rsnapshot config: replace spaces with tabs

rsnapshot is quite picky in its config: the commands have to be separated by TABs and not spaces. if you use rsnapshot configtest you see the errors, but how can I automatically repair the errors ...
8
votes
3answers
999 views

How to print strings separated by TAB in bash?

I am trying to print two string separated by a TAB. I have tried: echo -e 'foo\tbar' printf '%s\t%s\n' foo bar Both of them print: foo bar Where the whitespace between the two is actually 5 ...
0
votes
2answers
61 views

Gnu Sed: Space Character class not matching for end of line character

Pattern: abc followed by space or is the last character in a line. orig="abc[[:space:]]+"; new=Hello sed -i -r -e "s|${orig}|${new}|g" ./file ; File: abc abcd abc abc d After executing: abc abcd ...
0
votes
2answers
78 views

bash: convert array into string preserving white spaces

I am just trying to convert an array into string, while preserving the white spaces. This is what I have: INPUT=$1 readarray -t arr < <(grep -o . <<< "$INPUT") echo "${arr[*]}" I ...
-1
votes
2answers
46 views

How to trim the spaces from first and last of the variable string in Linux? [closed]

I am trying to remove white spaces from each variable string. I tried with below command but no use. a="HARISH , SAM" echo $a|sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
0
votes
1answer
23 views

sed alters windows line endings unintentionally. How can I avoid that?

I am developing in linux a portable application, in which I wanted to remove trailing spaces from some source files, which have windows style line endings. The line endings should not be changed to ...
0
votes
2answers
280 views

sed: remove extra whitespace to single whitespace between strings while leaving leading tabs intact

I have a code: 1 /** 2 a b c 3 **/ 4 int main() { 5 int x; 6 if ( condition) { 7 return x; 8 } 9 } I need to change multiple whitespaces between ...
0
votes
3answers
76 views

Unix command to remove space from a file name

I have a file whose file name has a space like First Name_20180810.csv. The date (20180810 in the above example) changes daily in the filename. How can I rename First Name_*.csv to be FirstName_*.csv?...
6
votes
1answer
444 views

How to compile Linux kernel modules within white-space-separated directories under the following makefile?

I was trying to compile a kernel module source code, until I noticed that some whitespaces where causing mismatched path names. The directory under which I found myself was: axor@vacuum:~/software/CS ...
1
vote
1answer
88 views

Bash script Issue parsing text in line with whitespace characters

I have a list of commands to parse through for an audit, similar to this: 1. -a *policy name=PolicyName -a *policy workflow name=PolicyWorkflow -a *policy action name=PolicyAction -s Server -b ...
1
vote
3answers
113 views

How to left pad a column in Bash

I have a bash script that prints the following results: 120,900 1160,001 80,730 600,165 6,310 1111,203 I would like to left pad that so the result will be: 120,900 1160,001 80,730 600,165 6,...
1
vote
1answer
102 views

Bash script read a string with whitespace [duplicate]

I am trying to write a quick bash script to automatically git push to multiple branches at once. My issue is, when I enter my commit message as a read variable, bash and git freak out at the use of ...
0
votes
1answer
1k views

Using string with whitespace in the subprocess.call function in python

I am trying to use ssh command in the subprocess.call function of Python 2.6.8 on Unix environment to call a remote script, and I need to provide a string parameter (with whitespaces) to the remote ...
2
votes
6answers
1k views

How can I trim the contents of a text file?

I want to remove all "blank" characters from the very beginning and the very end of a text file, including \n if exists. (basically mimicking the behaviour of trim() function of most programming ...
1
vote
2answers
91 views

Replace a specific line keeping identation

I have a file that has indentation. I want to replace a specific line but keep the indentation. The file has a line such as \t\t customerId = "123" // has indentation in the start of line I ...
0
votes
2answers
1k views

Correct way to match a leading space with sed (all of them)?

How to match a leading space with sed (all of them)? I'm not talking about leading tabs, but rather only on leading spaces. From a small test I did in Nano this seems to be correct: sed "s/^ //g" ...
2
votes
1answer
2k views

Binary operator expected - quoting question for shell script args

I have a question on how I'm adding arguments when executing a shell script. I have a simple script which helps me block ip ranges: ~/block_ip.sh: if [ ! $3 ] then echo "usage ~/block_ip.sh (DROP/...
2
votes
4answers
105 views

Ignore spacing between echo strings

I use echo to print two strings into a file in either of these two commands: echo -e "\n""x" >> ~/file echo -e "\n" "x" >> ~/file The first result is: x The second result is: x I ...
0
votes
1answer
42 views

script parameter containing spaces invoking mediainfo

I'd like to create a small shell script that will tell me the duration of a video whose file name is passed to it as a parameter. It'd be something like this: $ script_name "file name with spaces....
2
votes
1answer
74 views

Differences in whitespaces between bash script and interactive shell

Please advice why this happens. from a Linux bash shell: ps PID TTY TIME CMD 20406 pts/0 00:00:01 bash 26896 pts/0 00:00:00 ps I run the follwing str="a b c d" printf "%s\n" ` echo ...
2
votes
1answer
143 views

Remove whitespace only between two characters { and } in file [duplicate]

I have file with json values : abc={"adf": "def", "abc2":"def2", "abc3" : "def3" } abc4= 1 abc = {hello : world, hello:"a"} I want to remove whitespace from everywhere in between { and } and not ...
3
votes
1answer
780 views

how to get less to show tabs as tabs?

When I view data with tabs in less, tab characters are expanded to spaces. If I then copy them directly out of my terminal using ctrl-c, they copy as spaces. On the other hand, more preserves tab ...
2
votes
0answers
202 views

How to open a file in MonoDevelop with spaces in the path?

I have installed MonoDevelop using the instructions here on my PC running Arch Linux. I can successfully launch the MonoDevelop IDE using the command: flatpak run com.xamarin.MonoDevelop I can also ...
1
vote
1answer
719 views

How to display trailing whitespaces in the text file?

I'd like to be able to print and see the trailing whitespaces in the text file (just display, not remove). I've tried with cat -v which suppose to display non-printing characters, but it doesn't ...
2
votes
1answer
134 views

Cut delimited with unescaped space?

I have a file with text in the format of: User\ Name My\ Password Notice this is actually a 2 column file, where columns contain escaped spaces. cut -d' ' -f2 produces Name but I want to produce My ...
1
vote
3answers
276 views

Print only certain columns while maintaining white space

I have some code that prints select columns from the output of lsblk. However, the spacing in the result makes it hard to read. Is there anyway to do this while maintaining the white space? echo "`...
6
votes
5answers
2k views

Replace any number of tabs and spaces with single new line in Linux? [closed]

I have a very large word list that has been damaged, maybe by improper vim exit or memory exhaustion? Everything in my word list should be left-justified. But now it is like this: Cat ...
0
votes
1answer
181 views

Any way to change the tab size of the diff command's output?

I'm on OSX and running a diff command like this, to create side-by-side output: $] diff -Bbwy --width=200 --suppress-common-lines file1.txt file2.txt > diff-output.txt It outputs my diffs just ...
2
votes
1answer
254 views

Quoting a path that contains spaces, in FreeBSD - why doesn't it always work?

I have a directory on my FreeBSD server whose contents are created by Windows users over Samba. The filenames and paths within it sometimes contain spaces, as is common in the Windows world. I just ...
2
votes
1answer
2k views

Passing arguments with spaces and quotes to a script (without quoting everything)

The following works great on the command-line: $ ffmpeg -i input.m4a -metadata 'title=Spaces and $pecial char'\''s' output.m4a How do I parameterize this command and use it in a script/function? I ...
1
vote
1answer
64 views

Passing paths and filenames to a program from bash script

I use a utility called mp3wrap which combines multiple mp3s into one. Say I have a directory "album 1" containing three files "track 1.mp3", "track 2.mp3" and "track 3.mp3". I will run the following: ...
12
votes
4answers
899 views

bash: whitespace-safe procedural use of find into select

Given these file names: $ ls -1 file file name otherfile bash itself does perfectly fine with embedded whitespace: $ for file in *; do echo "$file"; done file file name otherfile $ select file in *;...
3
votes
1answer
237 views

Zsh preexec - How to trim all leading indentations from a codeblock?

Say I copy the following codeblock from a .md handbook which incldes some information and a few codeblocks (hence it's not a script file): ⇨⇨⇨⇨( ⇨⇨⇨⇨Indented commands... ⇨⇨⇨⇨) The Zsh preexec ...
3
votes
1answer
3k views

Posix Character Sets difference between [[:blank:]] and [[:space:]]?

On this website it says: [[:blank:]] space and tab characters [[:space:]] whitespace characters What's the difference between space and tab characters and whitespace characters? To me, they ...
1
vote
1answer
73 views

Can I force column to emit whitespaces instead of tabs?

I'd like to tabularize a file with the column command: $ column -c 60 file.txt The output is nice on the screen, but unusable for my purposes because the items are seperated by tabs. for further ...
5
votes
1answer
703 views

Replace each tab ONLY at the beginning of each line with spaces

So replacing all tabs in a file with spaces is not hard. In vim for example, I can do %s/\t/ /gc And if I want to replace the ones at the beginning of each line, not the one in the middle I can ...
0
votes
0answers
30 views

Passing filenames with space between scripts [duplicate]

I've got a script that processes filenames given as parameters on the command line. This is a stripped down version to demonstrate the processing: #!/bin/bash # Just a test to see if parameter ...
1
vote
1answer
422 views

Git Server: ignore whitespace changes in new commits

I found a lot of ways to deal with the whitespace problem in Git, but all of them require some sort of action on the user side: configure Git to ignore ws changes, setup a pre-commit hook with warning,...
3
votes
1answer
112 views

Wordsplitting occurring in quoted variable

I'm trying to create a dialog menu based on the results of the lsblk command. My goal is to read the first word as the menu item and the remaining words as the menu item description. For example: ...
1
vote
2answers
271 views

Entering a folder with whitespaces and escape characters using bash

I have access to a list of folders that have a format like lastname, firstname(id) When I try to enter the folder from the terminal, it looks like cd test/lastname,\ firstname\(id\) I am not sure ...
4
votes
2answers
260 views

Maintain filenames as separate arguments in successive commands

A disclaimer: This isn't related to one specific command like ls or grep, although I use them in the examples, this is more a bash thing. Let's say I want to see the file sizes, timestamps, and ...
0
votes
3answers
1k views

Removing space at the beginning of the variable data

I would like to ask if how can I remove the space in the beginning of the stored data of the variable. I had an auto-generated script that will get MySQL COUNT from the DB. MYSQL COUNT SCRIPT-> .ini ...
-1
votes
1answer
119 views

Read file and write output in another file using shell script

My input file is: Employee e_id e_name 100 abc 101 xyz 102 pqr Salary e_id e_salary 100 12345 101 67890 Dependents e_id depp1 depp2 100 qwer tyui 102 asdf ghjkl I want the output line by line as ...
10
votes
4answers
2k views

Why does cut fail with bash and not zsh?

I create a file with tab-delimited fields. echo foo$'\t'bar$'\t'baz$'\n'foo$'\t'bar$'\t'baz > input I have the following script named zsh.sh #!/usr/bin/env zsh while read line; do <<&...
1
vote
3answers
336 views

How to delete whitespace surrounding equal signs in a string?

I'm trying to determine a way to delete leading and trailing whitespace surrounding the equal sign from a string. The whitespace may (or may not) be present. There may be 0, 1 or more equal signs. I'...
1
vote
1answer
113 views

How can I edit my bash script to account for whitespace entries? [duplicate]

I made a script to automate ffmpeg conversion from mkv > m4v > open the m4v in Subler.app to import the metadata manually, at which point I'll move the file into my iTunes library. I use iTunes ...
2
votes
1answer
372 views

Change to a directory containing a space

I'm using a MacBook with OS X installed. I'm on Terminal trying to go to a directory. So I'm in Home and I use the command ls and there is a VirtualBox VMs directory. But when I try to do cd ...
4
votes
1answer
5k views

Octals 302 240 together seem to correspond to non-breaking space

By looking at a particular line of a text file (say, the 1123th, see below), it seems that there is a non-breaking space, but I am not sure: $ cat myfile.csv | sed -n 1123p | cut -f2 Lisztes feher $ ...
1
vote
0answers
21 views

Creating command from some of the arguments to a bash script including whitespaces [duplicate]

I have a bash script that takes some arguments and uses some of them to loop over some action while some others (those of the form 'a=b') are passed to that action. Essentially, it looks like args= ...