Covert array date string and decrease 3 hours in Shell Script [closed] - arrays

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I need from an array decrease 3 hours from it and print in command line again
the output of the array is:
12:29:14
14:10:26
14:30:34
14:35:31
14:35:10
11:57:03
12:49:31
12:57:09
11:04:49
13:06:57
14:35:34
14:30:49
14:34:28
12:58:02
14:28:12
12:29:18
11:33:23
12:27:04
14:35:43
12:58:46
I am trying with this line, but no use.
date2=$(date -d "${array[#]}" "3 hour ago" +"%H:%M:%S")
Could you please help me about it?

try this;
#!/bin/bash
times=( "12:29:14" "14:10:26" "14:30:34" "14:35:31" "14:35:10" "11:57:03" "12:49:31" "12:57:09" "11:04:49" "13:06:57" "14:35:34" "14:30:49" "14:34:28" "12:58:02" "14:28:12" "12:29:18" "11:33:23" "12:27:04" "14:35:43" "12:58:46")
for dateItem in ${times[#]}
do
date2=$(date --date="$dateItem 3 hour ago" +%H:%M:%S)
echo $date2
done

Hi It's worked after doing some changes it works correct,
If you wish todo it without an array
Here it is:
date2=$(date -d "$times 3 hour ago" +"%H:%M:%S")
echo $date2

Related

Unable to create database in Codeql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
Improve this question
I'm trying to create a database in Codeql but I'm unable to do it.
My input project is a simple hello.c in "/home/puya/Desktop/test" directory, and its source code is:
#include<stdio.h>
int main(void) {
printf("HELLO World!");
return 0;
}
and my command to create database is:
./codeql database create /home/puya/Desktop/database --language=cpp --source-root /home/puya/Desktop/test
and the output is:
enter image description here
enter image description here
Can anyone help me?

How to use variables in django url path? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am developing and Django website, and I have an array of some str values(parts of url).When user is redirect to:
https://www.example.com/something/name/
how can system system knows that that is part of that arry.
I alredy have this:
urlpatterns = [
path(r'<name1>, views.example')
]
And Array:
arr = [name1,name2,name3, ....namen] # elements of array are assigned to variables in for loop.
Thank you in advance.
So you need to change urlpatterns to:
path('<str:name>,views.example)
str is data type, and other data type for this use are:
int – Matches zero or any positive integer.
str – Matches any non-empty string, excluding the path separator(‘/’).
slug – Matches any slug string, i.e. a string consisting of alphabets, digits, hyphen and under score.
uuid – Matches a UUID(universal unique identifier).
And function call to:
views.example(request, name = "name_n") # for better code reading use name_1, name_2, .. name_n instead of name1,name2 etc.
and that would be it, enjoy in Django.

How to get the Query values? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
SqlDatasource1 :
Table1
-----------
Result_1
-----------
Result_2
I have a query, and I want to get a Result_2 value from the query in code behind, in the BeforePrint event, and I don´t want to put a label in the report, how can I do this?
Thanks
If you want to manually run the Select command on your data source, you could try something like (C#):
var dv = new DataView()
dv = Sqldatasource1.Select(DataSourceSelectArguements.Empty) as DataView;
if (dv.Count > 0)
{
foreach (DataRowView rv in dv)
{
string Result2Val = rv["Result_2"].ToString();
// do something with the result...
}
}
I'm sure VB will follow a similar pattern.
Alternatively, try and capture the OnSelected event, if it's already being triggered by another control.

Can I use while(strstr(name[a],sname)!=NULL) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I'm writing a phonebook application and one of the functions is for searching the phonebook by name.
The program should print out the names the same way as the user entered them (later I will include the numbers and other info). The phonebook has 100 contacts.
sname is the name that user have entered to search.
name[a] is name list. Is there any other code like strstr? Like its operating if its found printing them if not then print("not found any") something like this:
for(a=1; a<101; a++) {
while(strstr(name[a],sname) != NULL) {
printf(strstr(name[a], sname));
}
}
You can do that: it is an infinite loop.
while(strstr(name[a],sname)!=NULL){
printf("%s\n",strstr(name[a],sname));
}
None of a, name[a], sname change in the conditions or body of the while

C - 2 conditions in if statements [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
hope you have a solution for me, here my matter:
if (!strcmp(bgcolor,"RED")&& (ekey & keyup) {*strncpy(bgcolor,"GREY",5);}
How can i execute this in the right way?
Edit: Thanks, newbie here,
Edit: ehm... what about this?
if (ekey & keyB && (ekey & keyup && (!strcmp(bgcolor,"RED")))) {*strncpy(bgcolor,"GREY",5);}
You have a syntax error in your snippet, more specifcally the parentheses are not matched properly (you are missing the closing paren surrounding the if-condition).
You are probably looking for something as:
if (!strcmp (bgcolor, "RED") && (ekey & keyup)) {
strncpy (bgcolor, "GREY", 5);
}
Note: Notice the )) after keyup...
Try this
if (!strcmp(bgcolor,"RED") && (ekey & keyup))
{
strncpy(bgcolor,"GREY",5);
}

Resources