spaces

BASH shell expand arguments with spaces from variable [duplicate]

社会主义新天地 提交于 2019-12-01 07:39:32
问题 This question already has answers here : Bash doesn't parse quotes when converting a string to arguments (4 answers) Closed 3 years ago . Say I have a variable $ARGS which contains the following: file1.txt "second file.txt" file3.txt How can I pass the contents of $ARGS as arguments to a command (say cat $ARGS , for example), treating "second file.txt" as one argument and not splitting it into "second and file.txt" ? Ideally, I'd like to be able to pass arguments to any command exactly as

Building command strings using variables with various quote levels and spaces

爷,独闯天下 提交于 2019-12-01 06:46:24
问题 I have a script that runs curl . I want to be able to optionally add a -H parameter, if a string isn't empty. What's complex is the levels of quoting and spaces. caption="Test Caption" if [ "${caption}" != "" ]; then CAPT=-H "X-Caption: ${caption}" fi curl -A "$UA" -H "Content-MD5: $MD5" -H "X-SessionID: $SID" -H "X-Version: 1" $CAPT http://upload.example.com/$FN The idea is that the CAPT variable is either empty, or contains the desired -H header in the same form as the others, e.g., -H "X

Faster way to remove 'extra' spaces (more than 1) from a large range of cells using VBA for Excel

别等时光非礼了梦想. 提交于 2019-12-01 06:13:56
问题 How do I remove extra spaces faster, from a large range of cells containing text strings? Let's say 5000+ cells. Some ways I have tried include: For Each c In range c.Value = Trim(c.Value) Next c and For Each c In range c = WorksheetFunction.Trim(c) Next c and For Each c In range c.Value = Replace(c.Value, " ", " ") Next c Any ideas for speed improvement? 回答1: The loop is killing you. This will remove spaces in an entire column in one shot: Sub SpaceKiller() Worksheets("Sheet1").Columns("A")

C programming: print only int from fgets

♀尐吖头ヾ 提交于 2019-11-30 19:31:34
See this main : int main(void) { int i; int ch; char str[512]; fgets(str, sizeof str, stdin); for (i = 0; i <= (strlen(str)); i++) { if (str[i] != '\0' && str[i] != '\n') { int num = atoi(&str[i]); printf("%d\n", num); } } return 0; } I want to get line with numbers from user and get all the numbers without any spaces or tabs . For example: The input 1 2 3 . But in this case this the output: 1 2 2 3 3 So why i received 2 and 3 twice? Here's how I would do it: char line[256]; if (fgets(line, sizeof line, stdin) != NULL) { const char *ptr = line; while (*ptr != '\0') { char *eptr = NULL; const

are leading and trailing whitespaces ignored in html?

冷暖自知 提交于 2019-11-30 18:55:36
问题 html4 says this: In order to avoid problems with SGML line break rules and inconsistencies among extant implementations, authors should not rely on user agents to render white space immediately after a start tag or immediately before an end tag. Thus, authors, and in particular authoring tools, should write: <P>We offer free <A>technical support</A> for subscribers.</P> and not: <P>We offer free<A> technical support </A>for subscribers.</P> and this: SGML (see [ISO8879], section 7.6.1)

How can I programmatically add a space to mission control?

扶醉桌前 提交于 2019-11-30 17:20:44
I want to create a new space (and also be able to delete it later), without having to go through the standard misson control gui. Is there any way to do this programmatically? Either via terminal commands, applescript or some cocoa? Vighnesh Pai There is on preference plist in ~/Library/Preferences path named as com.apple.spaces.plist. There You have to add two keys. Open the plist and I hope you will get to know it. From the GUI... ...just in case someone finds this via Google It’s a cinch: when you’re in Mission Control ... move your cursor to the upper right corner of the screen click the

C# - Easiest way to parse filename with spaces eg. “C:\Test\File with spaces.txt”

旧城冷巷雨未停 提交于 2019-11-30 16:57:19
问题 I am trying to pass a full file path to FFMPEG. C:\TestFolder\Input\Friends - Season 6 - Gag Reel.avi and it's obviously not liking the fact the path has spaces in it, erroring like so: C:\TestFolder\Input\Friends: no such file or directory So what's the easiest way to use filenames with spaces in them? Should I just replace all whitespaces with ~ characters or is there a better way? I have tried escaping the string with various characters: @"C:\TestFolder\Input\Friends - Season 6 - Gag Reel

How do I replace tabs with spaces within variables in PHP?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 07:26:07
问题 $data contains tabs, leading spaces and multiple spaces. I wish to replace all tabs with a space. Multiple spaces with one single space, and remove leading spaces. In fact somthing that would turn this input data: [ asdf asdf asdf asdf ] Into output data: [asdf asdf asdf asdf] How do I do this? 回答1: $data = trim(preg_replace('/\s+/g', '', $data)); 回答2: Trim, replace tabs and extra spaces with single spaces: $data = preg_replace('/[ ]{2,}|[\t]/', ' ', trim($data)); 回答3: Assuming the square

Handle spaces in argparse input

孤者浪人 提交于 2019-11-30 05:58:52
Using python and argparse, the user could input a file name with -d as the flag. parser.add_argument("-d", "--dmp", default=None) However, this failed when the path included spaces. E.g. -d C:\SMTHNG\Name with spaces\MORE\file.csv NOTE: the spaces would cause an error (flag only takes in 'C:SMTHNG\Name' as input). error: unrecognized arguments: with spaces\MORE\file.csv Took me longer than it should have to find the solution to this problem... (did not find a Q&A for it so I'm making my own post) For those who can't parse arguments and still get "error: unrecognized arguments:" I found a

How do I convert a list into a string with spaces in Python?

我是研究僧i 提交于 2019-11-30 04:09:00
How can I convert a list into a space-separated string in Python? For example, I want to convert this list: my_list = [how,are,you] Into the string "how are you" The spaces are important. I don't want to get howareyou as I have with my attempt so far of using "".join(my_list) " ".join(my_list) you need to join with a space not an empty string ... Polaris I'll throw this in as an alternative just for the heck of it, even though it's pretty much useless when compared to " ".join(my_list) for strings. For non-strings (such as an array of ints) this may be better: " ".join(str(item) for item in my