Another Question, Linux Pros, And Noobs, Take A Crack.

to create a directory named sysadmin1/my_peeps/$DATE ,, am i to: echo sysadmin1/my_peeps/$DATE >> .bash_login ?? or do i: vi .bash_login and manually type the commands in there??,, i have the DATE variable already set. im looking for another way besides using mkdir.. thats my first question..

my real problem and second question is, how do i redirect the output of the w command to a file in my_peeps.. so, after that dir is created, do i do w > sysadmin1/my_peeps ??


Similar Content



Linux Pro's And Noobs! A Challenge, Please Take A Crack At This! (TIME SENSATIVE,)

Do it like this is your situation, your server, and the dir that are mentioned below, act like they are yours! im just looking for an accurate answer!
(student of O'Rielly School of Tech)


whenever you log in, your shell executes commands that it finds in your dotfiles, specifically .bash_login. In your .bash_login, add a series of commands that will first create a directory named ~/sysadmin1/my_peeps/$DATE, where $DATE is today's date in the format mmddyy. This command should succeed whether or not the directory ~/sysadmin1/my_peeps already exists. Then, it will redirect the output of the w command (which lists the currently logged in users on the system) to a file inside this newly created directory called users.$TIME, where $TIME is the current time in the format hhmmss (use 24 hour time).

In order to do this, you must use a new concept: assignment of a variable from the output of a command. For example, in order to set the variable EXAMPLEDATE using the unformatted output of the date command, you would do the following:

EXAMPLEDATE=`date`

The characters surrounding the date command are called "backticks." They are usually located on the same key as ~. They are not single quotation marks. This is actually another kind of expansion called "Command Substitution" (you can learn more in bash's manpage).

For this project, you can use the date command to get both the date and the current time, however, you will have to consult date's manpage to find out how to change the formatting.

Script Queries

Hi,

Below is the output of the "date" command:
Thu Apr 2 16:07:59 SGT 2015

After assigning the output to a parameter as follows:
DATE=`date`

The output has changed when "echo $DATE":
Thu Apr 2 16:09:40 SGT 2015
^^

The "2" has moved forward.

I don't want the "2" to move forward, please advise how to go about it.

Thanks in advance.

How: Date Of The Command Ran?

Hi Forum members,

I'm interested to get the date on which particular command was ran.

I've below in my .bashrc

Code:
export HISTTIMEFORMAT="%d/%m/%y %T "

I ran history | grep "cp" | less

I get an output like:

Quote:
1288 27/05/15 09:12:55 sacct -j 767151 --format=elapsed,ncpus,state
27/05 is today's date. But I'm interested for the date, the above output was ran.

What am I missing?

Process Substitution With Awk, Output Splitting Incorrectly

I have the following code to extract two dates using awk, which are then read into two awk variables new and old respectively.
Each dates on the html file pulled with curl request is in this format:
2015-04-06 09:40:37
And two are being extracted
However the strings are being split on white space within the date strings. I tried changing OFS to ',', but it was still splitting incorrectly.
Code:
read dateStrNew dateStrOld < <(curl -k -q "$curl_call" | html2text | gawk '/Newest Sequence/ { new=$3" "$4 }/Oldest Sequence/ \
 {old=$3" "$4}END {OFS=","; print new,old }')  //new = date, old = date

Both parts of the date are being assigned to each variable using $3 and $4, then the space needs to be added back in so that the string can be used afterwards with a date command.

I just can't work out what is wrong, any help would be very much appreciated! Thanks!

TimeZone Problem

Dear Friends ,

My date value shows One hour ahead from the present time in BDT . I stay on Asia/Dhaka zone and +6.00 . Please look @ the below output :

------------------------------------------------------------
[root@pbldc-ntpsrv Asia]# cat /etc/sysconfig/clock
# The ZONE parameter is only evaluated by system-config-date.
# The timezone of the system is defined by the contents of /etc/localtime.
ZONE="Asia/Dhaka"
UTC=true
ARC=false
-------------------------------------------------------------


But , My problem is , the below Date command output shows 'BDST' instead of 'BDT' .
------------------------------------
"[root@pbldc-ntpsrv Asia]# date
Sat May 9 16:59:37 BDST 2015
-------------------------------------
But it should be :

---------------------------------
[root@pbldc-ntpsrv Asia]# date
Sat May 9 15:59:37 BDT 2015
---------------------------------

---------------------
[root@pbldc-ntpsrv ~]# date +Z
BDST --Should be BDT
[root@pbldc-ntpsrv ~]# date +%z
+0700 --Should bt +0600
[root@pbldc-ntpsrv ~]#

------------------------------------


How I fix it in redhat lnux 5.5 server .

Redirection. Help Pls.

Hello there. Im stuck on a task.

it`s the task:
Search the file 'data' for all of the lines that contain the pattern 'linux'
and put those lines in the file 'matches'.

You entered: grep "linux" date > matches
Please try again.

I tried lots of variants
1) grep linux date > matches
2) grep 'linux' date > matches
3) grep linux date >> matches

May be something`s wrong with grep command?
I just dont get it >.>; it should work fine. Where is my mistake folks?

Bash Echo Date+string In The Same Line

I would like to print the date followed by a string (an indication of what's going on at that time) to a file. With this intention I've tried

Code:
date >> date.txt && echo "something start" >> date.txt

That gives me

Code:
Sun May 17 01:08:28 BRT 2015
something start

How to get both at the same line? Like this

Code:
Sun May 17 01:08:28 BRT 2015 something start

Create Date

Someone told me there is no such thing as a (file) "created_on" date in Linux...

File Time Stamp And Time As Printed By Date Showing Difference

Hi
Please see below actions.

$ touch abcd #abcd does not exist before
$ ls -l abcd
-rw-r--r-- 1 james games 0 Apr 17 15:01 abcd
$ date
Fri Apr 17 15:39:55 IST 2015

Why is there about 38 minutes difference even though I type commands in quick succession ?

Thank you.

Equivalent In Linux For The Dos Command Dir *.exe /s

Hello,

I studied the command ls for more than 3 hours and I want to do in linux the following commands

1) cd \
2) dir *.exe /s

This browse my entire disk and displays all the executables.
Also I want to see the attributes, the subdirectory, the filename, the file length and the date of creation.

Can somebody help me to make a bashfile with the correct ls switches ?
It should be someting like
cd root
ls -1 -? -?

Thank you very much.