The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
3answers
64 views

How to sort filenames with spaces in them and concatenate the files?

I have the misfortune of dealing with filenames that contain spaces. I want to concatenate files of which filenames contain spaces. I also want to sort the filenames numerically. Obviously the ...
0
votes
0answers
19 views

Print the page count within the PDFs in a directory to a output txt file [duplicate]

The need has been to identify the total page count of all the PDF files we have in a repository. For that, I was able to come up with the following script. However, I'm now stuck with this situation: ...
1
vote
1answer
86 views

shell for loop with find with filenames containing spaces [duplicate]

Consider a directory with typical Microsoft Windows filenames: New Document.txt Foo.doc Foo - Copy.doc I'd like to do something on each file such as: for sendfile in $(find ${POLLDIR} -type f ...
1
vote
2answers
93 views

bash question about if and then [duplicate]

I'm writing this in my script. It has other parts but I'm getting stuck on this part only. if [[$# == $year $month $day ]] ; then cal $day $month $year fi When I run this it give me this msg: ...
2
votes
1answer
556 views

Storing whitespace in a shell script variable [duplicate]

I need to store specific number of spaces in a variable. I have tried this: i=0 result="" space() { n=$1 i=0 while [[ "$i" != $n ]] do result="$result " ((i+=1)) ...
3
votes
3answers
250 views

What perl script will scp directory with spaces in name?

I"ve been trying for several hours to figure out how to get perl to scp a directory with a space in the name. I'm currently getting the error scp: ambiguous target Here is the script that is not ...
3
votes
1answer
427 views

Rename files with spaces in a BusyBox shell

I'm trying to rename some files on my Synology Diskstation via SSH. The available shell is the BusyBox built-in shell: BusyBox v1.16.1 (2013-04-16 20:13:10 CST) built-in shell (ash) The move ...
1
vote
3answers
241 views

Brackets in if condition: why am I getting syntax errors without whitespace?

I am using the below script to move two days back when script runs at starting two days of the year and also check first and second days of every month and move two days back. if [$month="01"] ...
2
votes
1answer
137 views

csplit not obeying backslash r \r as carriage return

I have a file with \r\n line endings (CRLF carriage return line feed). This command works: $ csplit --silent --prefix=email-emailbad.txt- \ --digits=3 emailbad.txt '/^\.^M/'+1 '{*}' This ...
22
votes
3answers
2k views

Why does my shell script choke on whitespace or other special characters?

Or, an introductory guide to robust filename handling and other string passing in shell scripts. I wrote a shell script which works well most of the time. But it chokes on some inputs (e.g. on some ...
0
votes
1answer
51 views

Why does vim jump down to same position after multiple spaces?

I really can't find the answer to this and I would like to understand what going on behind the scenes to make this happen. Is it a setting I have switched on? If so, which one? To give an example, I ...
2
votes
2answers
1k views

How to add a string with spaces at the end of command output

I want to add a string with spaces at the end of each line of the output of ls command. #!/bin/sh STRING_WITH_SPACES="this should be at the end of output" ls -lh | sed 's|$| '$STRING_WITH_SPACES'|' ...
1
vote
2answers
166 views

Why are bash tests so picky about whitespace?

As a primarily Java programer, I find the bash if-then construct quite confusing, especially regarding whitespace. Can anyone explain, why the first one works but not the second and third? #works if ...
4
votes
3answers
486 views

Why does bash have a HISTCONTROL=ignorespace option?

Or to phrase it differently, why would you want to prevent commands from being written to the bash history? (Inspired by a related question.)
12
votes
1answer
305 views

Why is bash not storing commands that start with spaces?

If I perform a sequence of commands like: $ ls $ grep abc file.txt and then use the up arrow key to get the previous one, the terminal will show the last cmd (which is the grep here) But if I do ...
1
vote
1answer
338 views

Sed: search and replace a patten with special characters which has a arbitrary string in between

I have a load of nfo files which I want to make some global substitutions for some values within each file e.g. a.nfo has the value <set>Tonight&apos;s Menu ( June 2012 )</set> ...
3
votes
1answer
140 views

Trailing spaces when copying from gnome-terminal using zsh

When copying text from gnome-terminal with zsh trailing whitespace is also copied. For example copying the following clearly adds a vertical scollbar on stackexchange site as trailing whitespace the ...
2
votes
3answers
1k views

How to identify and remove invisible whitespace characters on gedit?

I want to remove unnecessary whitespace on my css file. I am using grep with the command as follows: $ grep -rn "[[:space:]]$" Surprisingly, it is returning a hit on every line in the file. I ...
3
votes
1answer
170 views

terminal command that prints out tabs, spaces, and newlines as \t \s and \n

I wrote a terminal program in c that converts tabs to spaces. And I would like to see that it works and how many spaces were converted from tabs. The problem is when I create a file called input.txt ...
8
votes
3answers
188 views

POSIX compliant way to work with a list of filenames possibly with whitespace

I have seen Bash scripting guides suggesting the use of array for working with filenames containing whitespace. DashAsBinSh however suggests that arrays are not portable so I am looking for a POSIX ...
6
votes
4answers
3k views

how do I trim each line in bash?

I would like to remove all leading and trailing spaces and tabs from each line in an output. Is there a simple tool like trim I could pipe my output into?
1
vote
1answer
57 views

Emacs - Strange Whitespace

(I posted this same general question here on StackOverflow thinking it had something to do with my emacs configuration, but after following a comment there, I think it is exclusive to urxvt) My ...
5
votes
2answers
530 views

Quoted vs unquoted string expansion

for i in $(xrandr); do echo "$i" ; done for i in "$(xrandr)"; do echo "$i"; done for i in "$(xrandr)"; do echo $i; done I understand why 1 differs from 2. But why does 3 give a different output ...
0
votes
1answer
191 views

Unexpected whitespace using sqsh in command substitution [closed]

Below shell script instruction behave in weird way ARG_DATE=`sqsh -S $SERVER -U $DB_USER -P $DB_PASSWORD -D dbname -h<<END SET NOCOUNT ON go select convert(varchar, PRIOR_COB_DATE, 112) from ...
5
votes
2answers
290 views

Bash commands with spaces in them (git config or git-config?)

Please forgive me if this seems easy, but I only started learning Unix 2 days ago. Basically, I have been taught that when typing a command into the terminal it needs to be of the form: [command ...
6
votes
3answers
3k views

vi / vim - how to automatically strip trailing spaces on save?

Is there a .vimrc setting to automatically remove trailing whitespace when saving a file? Ideally (to be safe) I would like to only have this functionality for certain files, e.g. *.rb
0
votes
2answers
1k views

what is “an invisible whitespace character that takes up space”

One can look up Unicode Characters with Regular Expressions. On Jan Goyvaerts website I found a RegExp whose meaning I don't understand : \p{Zs} or \p{Space_Separator}: a whitespace character that ...
3
votes
2answers
242 views

Generic Preprocessor adds extra whitespace

Following up on this article I use GPP to empower Markdown parser pandoc with some macros. Unfortunately, gpp seems to copy all whitespace into the result. For example, consider file test.md % Title ...
2
votes
1answer
386 views

How to use whitespace in procmailrc recipe destination path?

I use Mutt Maildir for storage mails. I created one mailbox like this Stack Exchange/. (whitespace between Stack and Exchange here) procmailrc recipe: :0 * From: .*Stack\ Exchange Stack Exchange/ ...
2
votes
1answer
82 views

Emacs + whitespace: ignoring 'normal' spaces

I would like to use whitespace to detect wrong whitespace (i.e. trailing whitespace on line, tabs instead of spaces etc.). However I would like to still have spaces displayed as spaces. I tried to ...
6
votes
2answers
19k views

Removing all spaces, tabs, newlines, etc from a variable?

This is the error I am getting and it's failing because of a variable whose value is supposed to be 2 (I am getting this using a select * from tabel). I am getting spaces in that variable. + 0 != ...
4
votes
2answers
1k views

Using files that have spaces in their name in pipes

I have folder named play which contains a file damn file (with space). When I use find and pipe the output to tar: find play/ -name 'damn*' | tar cf archive.tar -T - It works perfectly. Why does ...
3
votes
2answers
5k views

Strip trailing whitespace from files

The answer to removing trailing whitespace with sed has most of the answer, but I want sed -i 's/[ \t]*$//' $1 to be able to take arbitrary number of file arguments as a shell script on the command ...
2
votes
1answer
663 views

Rsyncing multiple files with white spaces in the names

I'm trying to back up files onto a server, but I'm having problems with files that have white spaces in the names. I'm using this command in terminal: FILES="testing/space\ in\ filename testing/and\ ...
11
votes
1answer
10k views

Ignore whitespaces changes in all git commands

I've found tons of sites that explain how to have git warn you when you're changing line endings, or miscellaneous other techniques to prevent you from messing up an entire file. Assume it's too late ...