Tag Info

Hot answers tagged

42

You're seeing this behavior because of summer time (daylight saving time). Because you are currently in summer time, where your clock is one hour ahead, when you ask for three months ago at just after midnight on the first of June, the time ends up being one hour "earlier" because it was not summer time three months ago. The GNU date documentation suggests ...


13

If absolute timing is your primary concern, it's probably best to work off of UTC as it exists for that purpose. Michael's answer is very useful for when you have to work inside of the problem, but it's usually a good idea to avoid it entirely where you can. When your system isn't set to UTC by default, the simplest way to pass the timezone in is by ...


9

You disable it by adding the following line in your script: set -o noglob As an example, echo * your files and folders are shown here.. set -o noglob echo * *


8

You can put it into "": $ ls file1 file2 file3 file4 file5 file6 file7 file8 file9 $ Q='select * from table;' $ echo $Q select file1 file2 file3 file4 file5 file6 file7 file8 file9 from table; $ echo "$Q" select * from table;


7

tail -n 500 logfile >newfile should do the trick.


5

The reason is, unlike Linux, ifconfig without options isn't a valid command under Solaris. The equivalent command would be ifconfig -a. If you run it without options, ifconfig displays a help message on its standard error stream. To have it paginated, simply use: ifconfig 2>&1 | less By the way, ifconfig is somewhat obsolete under Solaris 11. I ...


5

http://www.tech-recipes.com/rx/742/kill-the-undesired-unix-processes-in-one-go/ has a nice write up of the usual answer for generic unix: pipe ps to grep, then to awk, then to xargs. As another poster mentioned, beware any glib answer that throws around "killall", since it has a radically different purpose on AIX and Solaris (at least) than it does on ...


5

[Pushing up from comments] Two options: Batch mode from text-based browsers such as links/lynx/w3m Use openssl s_client as noted here: Connecting to HTTPS with netcat (nc)


5

In all the snippets below, run the command to check if the files it displays are really the ones you want to delete. Then perform the deletion by replacing echo with rm or -print with -delete If all your files are in the same directory, you can remove the ones whose name starts with a digit. echo [0-9]*.jpg If your files live in a directory hierarchy, ...


4

From the man page The standard format is DDdays, HH:MMm, MM:SS or SS.CC if the times are greater than 2 days, 1hour, or 1 minute respectively. so your output is MM:SS (>1m and <1 hour).


4

Move everything in the directory in to another directory. Remove the original directory. Recreate the original directory. Move everything back. You are using a filesystem that can't shrink directories. There's always e2fsck -D which will optimize all directories on the filesystem.


3

What also might be useful if you're uncertain whether it's doing anything at all, is use 'strace'. If your app is the 'dhcpd' service, run ps ax | grep [d]hcpd $ ps axufw | grep [d]hcpd dhcpd 21645 0.0 0.1 19156 4956 ? Ss Oct02 0:00 /usr/sbin/dhcpd -f -q -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/ltsp/dhcpd.conf Your PID is 21645, so ...


3

The suggested way to execute local commands remotely via ssh is not to use eval. This is discouraged. Since you are storing the whole line in a variable, instead you could mydate=$(date; date; date); ssh rsync@example.org bash <<< "$(printf 'echo %q ' "$mydate")" Eval should only be used in legacy systems who do not provide safe tools like the ...


3

The OS X kernel prohibits read(2) operations on directories, so you'll never be able to use user-space tools to read directory entries directly. If you want to read directory entries from user space, you'll need to open the underlying block device directly, read its superblocks, find the root inode, read the entries to find the next directory in the chain ...


3

Here is one option for doing this. ls -d $PWD/*


3

Something like this would do it in bash (list all the state abbreviations in the list between in and ;): for s in ak al ar ; do cat *${s}_*.csv > $s.csv ; done If you have the state abbreviations in a file states.txt, the line could look like this: for s in `cat states.txt` ; do cat *${s}_*.csv > $s.csv ; done


2

Is /storage mounted as a separate filesystem? If so, you can simply type df /storage and that should work. The fact that the command is timing out suggests that it's a network filesystem. If so, what filesystem type is it? What's it provided by and how are you mounting it?


2

This is another way for individual files: readlink -e filename


2

Without a qualifier, it means MM:SS -- that is, minutes and whole seconds. As an added bonus, there's a fourth format you don't have in that output -- a number of days (NNdays) of inactivity.


2

There is no reason to compose such a long string of commands to run via SSH. Just make a permanent script on the remote host called /usr/local/sbin/rotate_backups and call it with ssh $USER@$HOST 'sudo /usr/local/sbin/rotate_backups'. If you were asking this on the "Unix & Linux" StackExchange, then this could be an interesting question. However, as ...


2

Try shell/bash build-in eval command: $ help eval eval: eval [arg ...] Execute arguments as a shell command. Combine ARGs into a single string, use the result as input to the shell, and execute the resulting commands. Exit Status: Returns exit status of command or success if command is null.


2

If your server has Internet connectivity, you will need to add a nameserver in your /etc/resolv.conf file nameserver 8.8.8.8 You can also replace 8.8.8.8 with our own dns server, if you have any.


2

As a follow up to Mariano Montañez Ureta. If you can see the task in the jobs window, all you should be able to see something like this: $ jobs [1]+ Running tail -f .ssh/known_hosts & If you then use the fg command coupled with the job number you can bring that to the foreground, i.e. fg %1 would bring my tail command to the ...


2

Try this: user@server:~$ remote_cmd=(ssh rsync@otherserver.example.org 'date; hostname -A; uname -a') user@server:~$ "${remote_cmd[@]}" It creates an array and executes it as suggested in BashFAQ/050 item 3.


1

df -k /var |awk '{print $4}' df -k |awk '$1 == "/dev/hd9var" {print $4}' df -k /var |awk '$3 < 1000 { system(send email)}' df -k /var |awk '$4 ~ /9.%/ || $4 == "100%" { system(send email)}'


1

use fg wich means foreground :)


1

Outside of the above pkill and killall answers, you can do the following, assuming you want to kill process "foo" ps -ef | grep [f]oo | awk {'print $1'} | xargs kill The grep [f]oo means that grep will not match the grep command itself, so it will just kill processes named "foo".


1

If you want the parent directory of the file you can use find and the -printf %h argument find /abc -name X.txt -printf "%h\n" /abc/dce %h Leading directories of file’s name (all but the last ele- ment). If the file name contains no slashes (since it is in the current directory) the %h specifier expands to ...


1

x="$(pwd)"; while [ "$x" != "/" ]; do if [ -e "${x}/X.txt" ]; then echo $x; fi; x="$(dirname "$x")"; done


1

Hmm, from the top of my head: Zabbix Nagios Munin Cacti ...



Only top voted, non community-wiki answers of a minimum length are eligible