Concatenating php date type variable with other strings while creating a custom file name in php - filenames

I have been trying to use my variable $date of type date to concatenate with some other string so as to make a custom file name which I will use it in my program.I tried the following ways after going through some links but I failed.
$bar="foo".$date.".txt";
$bar="foo".string($date).".txt";
$bar="foo"."$date".".txt";
It always omits $date variable and creates a file with name foo.txt. But I am looking for some thing like foo4/2/15.txt if value of $date is 4/2/15.
That would be great if some one help me with this.

Got the bug. It seems silly but may help some one in the same situation one or the other day.
My definition for $date is in a loop and the last definition was becoming null.So it always doesn't take any value for $date resulting foo.txt instead of foo2/4/15.txt.
As we discussed in the comments we also gotta take care of illegal file names.
Thanks for people above for their time.

Related

Multi-line text in a .env file

In vue, is there a way to have a value span multiple lines in an .env file. Ex:
Instead of:
someValue=[{"someValue":"Here is a really really long piece which should be split into multiple lines"}]
I want to do something like:
someValue=`[{"someValue":"Here is a really
really long piece which
should be split into multiple lines"}]`
Doing the latter gives me a JSON parsing error if I try to do JSON.parse(someValue) in my code
I don't know if this will work, but I can't format a comment appropriately enough to get the point across so see if this will work:
someValue=[{"someValue":"Here is a really\
really long piece which\
should be split into multiple lines"}]
Where "\" should escape the newline similar to how you can write long bash commands while escaping the newline. I'm not certain the .env interpreter will support it though.
EDIT
Looks like this won't work. This syntax was actually proposed, but I don't think it was incorporated. See motdotla/dotenv#333 (which is what Vue uses to parse .env).
Like #zero298 said, this isn't possible. Likely you could delimit the entry with a character that wouldn't show up normally in the text (^ is a good candidate), then parse it within the application using string.replace('^', '\n');

Replacing text string within quotes using sed or awk?

Both sed and g/awk seem very powerful. When I need data manipulated and struggle with syntax I always have answers submitted using both. Personally the syntax of awk is easier for me to grasp (is this common to have a preference?).
I want to spend a few days to trying to study tons of examples of using one or the other, should one specifically be focused on over the other? Does one out perform another in regard to capability? Now onto my question...
I have a .php file that is read and rendered as a json file. It looks like this:
<?php
$selectedSystemStateResults = ["Bird", "Cats", "Cows", "Dog",
"Goats", "Monkey", "Sheep"];
Using sed/awk how could I specify to change "Dog" to "Ducks" ?
Using sed/awk how could I specify to change the 5th variable to
"Impalas" ?
The first scenario I would know the name of the variable being changed, the second scenario I would just want the change the variable in a static position.
Disregard, overthinking it.
I simply modified the php file so that I could replace lines for now.
<?php
$selectedSystemStateResults = [
"Bird",
"Cats",
"Cows",
"Dog",
"Goats",
"Monkey",
"Penguin"]
;

How to use FILE_MASK parameter in FM EPS2_GET_DIRECTORY_LISTING

I am trying to filter files using FILE_MASK parameter in EPS2_GET_DIRECTORY_LISTING to reduce time searching all files in the folder (has thousands of files).
File mask I tried:
TK5_*20150811*
file name in the folder is;
TK5_Invoic_828243P_20150811111946364.xml.asc
But it exports all files to DIR_LIST table, so nothing filtered.
But when I try with;
TK5_Invoic*20150811*
It works!
What I think is it works if I give first 10 characters as it is. But in my case I do not have first 10 characters always.
Can you give me an advice on using FILE_MASK?
Haven’t tried, but this sounds plausible:
https://archive.sap.com/discussions/thread/3470593
The * wildcard may only be used at the end of the search string.
It is not specified, what a '*' matches to, when it is not the last non-space character in the FILE parameter value.

Apache Pig filtering out carriage returns

I'm fairly new with apache pig and trying to work with some fixed width text. In pig, I'm reading every line in as a chararray (I know I can use fixedwidthloader, but am not in this instance). One of the fields I'm working with is an email field and one entry has a carriage return that generates extra lines of output in the finished data dump (I show 12 rows instead of the 9 I'm expecting). I know which entry has the error but I'm unable to filter it out using pig.
Thus far I've tried to use pig's REPLACE to replace on \r or \uFFFD and even tried a python UDF which works on the command line but not when I run it as a UDF through PIG. Anyone have any suggestions? Please let me know if more details are required.
My original edit with a solution turned out to only work part of the time. This time I had to clean the data before I ran it through pig. On the raw data file I did a perl -i -pe 's/\r//g' filename to remove the rogue carriage return.

DCL sort - different start positions

I have a DCL script that creates a .txt file that looks something like this
something,somethingelse,00000004
somethingdifferent,somethingelse1,00000002
anotherline,line,00000015
I need to sort the file by the 3rd column highest to lowest
ex:
anotherline,line,00000015
something,somethingelse,00000004
somethingdifferent,somethingelse1,00000002
Is it best to use the sort command, if so everything i've seen required a position number, how can this be done if each line would have a different start position?
If sort is a bad way to handle this is there something else or can I somehow handle this while writing the lines to the file.
I've only been working with VMS/DCL for a few weeks now so i'm not fimilar with all of the commands yet.
Thanks!
As you already noticed, the VMS sort expects fields with a fixed start position within a record. You can not specify a field by a separator. If you want to use the VMS sort you have to make sure your third field starts at the same column, for all records. In other words, you have to pad preceding fields. If you have control on how the file is created, this may work for you. If you don't or you don't know how big the string in front of the sort field will be, this may not be a workaround. Maybe changing the order of the fields is an option.
On the other hand, you may find GNV installed on your system. Then you can try to use its sort, which is a GNU style sort. That is, $ mcr gnv$gnu:[bin]sort -t, -k3 -r x.txt may get you the wanted results.
VMS Sort is indeed not really equipped for this.
Reformatting as you did is about the only way.
If you so not have access to GNV sort on the OpenVMS system then perhaps you have, or can install PERL? Is is somewhat easier to install.
In perl there are of course many ways.
For example using an anonymous sort function ( $a is first arg, $b second; <> reads all input )
$ perl -e "print sort { 0+(split /,/,$b)[1] <=> 0+(split /,/,$a)[2]} <>" x.x
where the 0 + forces numeric evaluation. For (fixed length?) string compare use:
$ perl -e "print sort { (split /,/,$b)[2] cmp (split /,/,$a)[2]} <>" x.x
hth,
Hein.enter code here