unix

Bash script echo seems to remove my new lines? [duplicate]

懵懂的女人 提交于 2020-01-17 06:42:48
问题 This question already has answers here : I just assigned a variable, but echo $variable shows something else (7 answers) Closed 2 years ago . This is the contents of my file file.txt: header a b c I have no idea what is going on. This command does not print new lines. echo -e $(tail -n +2 file.txt) This prints: a b c But if you write it to file you will clearly see new lines: tail -n +2 file.txt >> new_file.txt test.txt a b c How do I force echo to print the new lines? I don't think I can use

How to check if a number is an integer in Pari/GP?

僤鯓⒐⒋嵵緔 提交于 2020-01-17 06:18:12
问题 I'm trying to write an if statement like this if(denominator([(i-1)! + 1] / i)-1,print(hi),print(ho)) i can be any integer for example 10, when I set i to 10 it gives this error. ? [(x-1)! + 1] / x *** this should be an integer: [(x-1)!+1]/x ^----------- I really only need to check if [(x-1)! + 1] / x is an integer or not the denominator thing is what I came up with, I also tried Mod but couldn't get that working either. 回答1: It seems that you are confused with the names x and i . Please, see

Do many files in a single directory cause longer loading time under Apache?

岁酱吖の 提交于 2020-01-17 05:58:25
问题 Even if there seem to exist a few duplicate questions, I think this one is unique. I'm not asking if there are any limits, it's only about performance drawbacks in context of Apache. Or unix file system in general. Lets say if I request a file from an Apache server http://example.com/media/example.jpg does it matter how many files there are in the same directory "media"? The reason I'm asking is that my PHP application generates images on the fly. Once created, it places it at the same

How to subtract or add days or months to a date on Solaris?

落花浮王杯 提交于 2020-01-17 05:19:19
问题 Linux date has the -d feature which is missing in Solaris. So how can I go about subtracting or adding days or months to a date on Solaris. 回答1: you still can do this with perl or python oneliners, e.g., substract one day from current date: $ date Thu May 14 15:31:49 MEST 2015 $ python -c "from datetime import datetime, timedelta; print (datetime.now() - timedelta(1)).strftime('%c');" Wed May 13 15:31:58 2015 回答2: What you need is GNU date for Solaris. (Linux uses GNU tools) If you are using

Getting an error with sed expression

时间秒杀一切 提交于 2020-01-17 01:10:08
问题 I am using this command in a shell script lnum=5 str="Hello foo" filename="/path/fiename" sed -i "$lnum i $str" $filename Getting the following error sed: -e expression #1, char 3: : doesn't want any addresses I had used this command before for other script it worked fine, the only change i made this time is file-name has a path to the file, but I tried it with just giving file-name and not the path by getting into the path and executing the script but still it doesn't work I am unable to

unix - diff command to output in single-line-per-difference format

删除回忆录丶 提交于 2020-01-16 18:59:11
问题 The version of diff in my cygwin has a number of advanced options which allow me to print out one difference per line. Given two files one.txt and two.txt. one.txt: one two three four five six two.txt one two2 three four five5 six And running diff in cygwin with the following options/parameters: diff -y --suppress-common-lines one.txt two.txt Gives an output of: two |two2 five |five5 This is the type of format I'm after whereby one difference is printed out per line. On my dev solaris box,

output redirection inside bsub command

旧时模样 提交于 2020-01-16 16:30:16
问题 Is it possible to use output redirection inside bsub command such as: bsub -q short "cat <(head -2 myfile.txt) > outputfile.txt" Currently this bsub execution fails. Also my attempts to escape the redirection sign and the parenthesis were all failed, such as: bsub -q short "cat \<\(head -2 myfile.txt\) > outputfile.txt" bsub -q short "cat <\(head -2 myfile.txt\) > outputfile.txt" *Note, I'm well aware that the redirection in this simple command is not necessary as the command could easily be

why does the date php and date unix does not match?

若如初见. 提交于 2020-01-16 14:48:00
问题 I have centos server and i rechanged the time to NewYork time by date cmd. Also i change in php.ini the "date.timezone = "America/New_York"" When i enter the command date in the command shell. i get the real time in new york. But when I do echo date("Y-m-d H:i:s"); The time isn't right! I always get 6 hours less then the time in New York. Please help? I tried already using date_default_timezone_set('America/New_York'); in the code with no help. waiting for a response. Thanks! Koren Or 回答1: i

why does the date php and date unix does not match?

无人久伴 提交于 2020-01-16 14:47:46
问题 I have centos server and i rechanged the time to NewYork time by date cmd. Also i change in php.ini the "date.timezone = "America/New_York"" When i enter the command date in the command shell. i get the real time in new york. But when I do echo date("Y-m-d H:i:s"); The time isn't right! I always get 6 hours less then the time in New York. Please help? I tried already using date_default_timezone_set('America/New_York'); in the code with no help. waiting for a response. Thanks! Koren Or 回答1: i

Java Swing ComboBox list of files from unix machine

只谈情不闲聊 提交于 2020-01-16 14:32:12
问题 I'm running my first simple Java Swing application from my UNIX environment. Currently it has an image and some buttons that do random things - one of which executes a command to my UNIX shell. I have a list of ".ksh" files in one of my directories on the UNIX machine that I'd like to read into a Swing GUI ComboBox. The dropdown items will populate from the list of files in the directory on the UNIX machine, and when i click a file from the list, it will execute the script in the UNIX shell.