File Name generated by passed variable getting special character appended - unix

I'm creating an archive filename by combining output folder and output file name which are both passed variables.
Example tar -czf $output_folder/$output_file.tar.gz.
However the generated file is getting an unicode character U+25AA appended, so it looks like output_fileU+25AA.tar.gz. What could be causing this? - I'm testing it on a Windows machine

Related

Fluent-bit, How can I use strftime in path

my log file name contains the current date, like my_log_210616.log
and I need to tail the file in fluent-bit. I tried with,
[INPUT]
Name tail
Path /var/log/my-service/my_log_%y%m%d.log
[OUTPUT]
Name stdout
Match *
but it doesn't watch the file. I replaced my_log_%y%m%d.log with my_log_210616.log, then it works.
How can I use strftime in the path?
One solution is to use a path that matches any date. Since fluent-bit will read the log files from their tail you won’t get data from the older files.
You could also add ’Ignore_Older 24h’ to the input config. This will ignore files with modified times older than 24 hours. Using ’Ignore_Older’ with a parser that extracts the event time works even better.
You could also do more elaborate filtering by file name in a lua filter.

Finding word in PDF

I would like to find some word after convert PDF.
1)I have 2 PDF at path C:\TRM\PDF 1.pdf and 2.pdf
1.pdf has word "ICG00058"
2.pdf has word "ICG00065"
2) Convert Pdf To Txt at ${detail_1} already.
3) Suppose, I don't know the word in 1.pdf and I want to check that
1.pdf has ICG00058 or ICG00065.
I'm so sorry,If the question is not clear.
Please investigate this issue for me cause It's paramount important for my work.
*** Settings ***
Library Selenium2Library
Library String
Library Pdf2TextLibrary
*** Test Cases ***
Read PDF
${detail_1} Convert Pdf To Txt C:\\TRM\\PDF\\1.pdf
LOG ${detail_1}
${ID_1} Get Regexp Matches ${detail_1} ICG00058
${ID_2} Get Regexp Matches ${detail_1} ICG00065
Run Keyword And Ignore Error $ID_1[0] in $detail_1 LOG ${ID_1}
Run Keyword If $ID_2[0] in $detail_1 LOG ${ID_2}
ERROR:
Evaluating expression 'RF_VAR_ID_2 [0 ]in RF_VAR_detail_2' failed: IndexError: list index out of range
I used pdfgrep just like grep you can search for regex expressions in the pdf without any intermediate step.
I used it to look up ISBN numbers in the pdfs and automatically rename the filename to include the found ISBNs or write the filename and ISBN to an MySQL database.
If you don’t know how to write regex there are some online tools to test regex online until you find the right one to use.
You need to call the Evaluate keyword if you want to run python within your robot script, that is why you are seeing the error you have mentioned.
In your case though you could use the Get Index From List and List Should Contain Value keywords:
${matched_id_1}= Get Index From List ${ID_1} 0
Run Keyword And Ignore Error List Should Contain Value ${detail_1} ${matched_id_1}
${matched_id_2}= Get Index From List ${ID_2} 0
Run Keyword And Ignore Error List Should Contain Value ${detail_1} ${matched_id_2}
If you want to use the List Should Contain Value keywords as assertions just remove the Run Keyword And Ignore Error keywords in the answer

Redirecting man to a file it is not identical to the text in the console

I am trying to print the man page for ls and I am getting output in my file with repeated characters. I am relatively new to bash and I dont know where to start with this issue.
This is the command I typed
man ls | cat > file.txt
I expected output like in the terminal
DESCRIPTION
For each operand that names a file of a type other than directory, ls displays its
name as well as any requested, associated information. For each operand that names a
file of type directory, ls displays the names of files contained within that direc-
tory, as well as any requested, associated information.
If no operands are given, the contents of the current directory are displayed. If
more than one operand is given, non-directory operands are displayed first; directory
and non-directory operands are sorted separately and in lexicographical order.
The following options are available:
-# Display extended attribute keys and sizes in long (-l) output.
-1 (The numeric digit ``one''.) Force output to be one entry per line. This is
the default when output is not to a terminal.
-A List all entries except for . and ... Always set for the super-user.
-a Include directory entries whose names begin with a dot (.).
-B Force printing of non-printable characters (as defined by ctype(3) and cur-
rent locale settings) in file names as \xxx, where xxx is the numeric value
of the character in octal.
-b As -B, but use C escape codes whenever possible.
-C Force multi-column output; this is the default when output is to a terminal.
But what I got as output in my file was like this
DDEESSCCRRIIPPTTIIOONN
For each operand that names a _f_i_l_e of a type other than directory, llss
displays its name as well as any requested, associated information. For
each operand that names a _f_i_l_e of type directory, llss displays the names
of files contained within that directory, as well as any requested, asso-
ciated information.
If no operands are given, the contents of the current directory are dis-
played. If more than one operand is given, non-directory operands are
displayed first; directory and non-directory operands are sorted sepa-
rately and in lexicographical order.
The following options are available:
--## Display extended attribute keys and sizes in long (--ll) output.
--11 (The numeric digit ``one''.) Force output to be one entry per
line. This is the default when output is not to a terminal.
--AA List all entries except for _. and _._.. Always set for the super-
user.
--aa Include directory entries whose names begin with a dot (_.).
--BB Force printing of non-printable characters (as defined by
ctype(3) and current locale settings) in file names as \_x_x_x,
where _x_x_x is the numeric value of the character in octal.
--bb As --BB, but use C escape codes whenever possible.
--CC Force multi-column output; this is the default when output is to
a terminal.
--cc Use time when file status was last changed for sorting (--tt) or
What would make it do this and how can I get the man page in readable text?
Some systems have a man program which notices whether it is sending output to the terminal or to a pipe and behaves differently in each case.
For example, on ubuntu linux, man man has an option:
MAN_KEEP_FORMATTING
Normally, when output is not being directed to a terminal (such
as to a file or a pipe), formatting characters are discarded to
make it easier to read the result without special tools. How-
ever, if $MAN_KEEP_FORMATTING is set to any non-empty value,
these formatting characters are retained. This may be useful
for wrappers around man that can interpret formatting charac-
ters.
In your case, it seems that man does not behave differently when sending output to a pipe.
There may be an option to turn on the behaviour you are looking for, but it may be simpler just to strip the unwanted characters out of the output. A common method is to use col:
man ls | col -bx > file.txt

list of files with space in the name

I would like to get the list of files with a specific extention in a folder. However, these files has space in the name. So for example, imagining I have files named file test1.txt, file test2.txt, file test3.txt, file test4.txt, if I do
list.files(pattern="file test*.txt")
I got
character(0)
NOTA: Apparentely, using simply pattern="file test*" it works fine but I need the extention file as well.
Try:
list.files(pattern="file test.*.txt")
Actually, what this says is:
list.files(pattern="file test(.*).txt")
(which also works). . refers to any character and * refers to the idea that this character should be present 0 or more times (see ?regex).
In your kast example you said that using pattern="file test*" works but you need a way to search for the extension as well.
All you have to do is Change your code to pattern="file test.*.txt". This would make your code search for any filename that matched "file testX.txt" with any one character in place of X.

i want to create a file with the system date in another directory and copy some data into it. Unix

I want to create a file with system date in another directory and copy data difference of two files into it.
NOW=$(date +"%H_%D")
file="log_$NOW.txt"
diff tmp1.txt tmp2.txt > $temp/log_$NOW.txt
i am using above code. But file is not getting generated. Apart from it if i create a file with simple name i.e without using $NOW the file is getting generated. Please help me.
The format string to date produces something like 16_12/03/13. This contains directory separators so the filename becomes invalid. Instead use dots to separate the date:
NOW=$(date +"%H_%m.%d.%y")
which should produce strings like 16_12.03.13

Resources