Skip to content
#!/bin/bash

Month: December 2023

stdout and stderr to same place

redirect both stdout and stderr to same place

Posted on 2023-12-13 | by root

Sometimes you might want to redirect both stdout and stderr to same place. You can do it like:

[root@linux ~]# ./script.sh >/dev/null 2>&1

But there is a shorter way…

Continue reading →
Posted in Tips and tricks, Tutorials | Tagged redirect, redirection, stderr, stdout
create results file only when finished

create results file only when fully finished

Posted on 2023-12-07 | by root

Idea behind this trick is very simple yet powerful enough. It allows you to avoid unexpected consequences when some results file is being appended long enough by your process.

Continue reading →
Posted in Tips and tricks | Tagged consistency, data, file, integrity
Linux CLI tips & tricks, shell scripting

run commands with timeout

Posted on 2023-12-06 | by root

Sometimes you might have use cases, when specific command or script should be run no longer than given amount of time. In those cases you should run commands with timeout.

Continue reading →
Posted in Tips and tricks | Tagged timeout

Recent Posts

  • bash generates random fun
  • exponential search in bash
  • dealing with float numbers in bash
  • loops in Linux shell scripts
  • negate something in regex using negative lookahead
  • convert wildcard in file name into relevant static file name
  • check ownership and permissions for absolute path easily
  • retrieving country codes from IP automatically
  • check if json is valid
  • redirect both stdout and stderr to same place

Archives

  • January 2025
  • August 2024
  • June 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
© 2025 shscripts.com | contact me: IN