Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

shell

List X random files from a directory

August 10, 2022 by Magenaut

Is there a way to list a set of say, 30 random files from a directory using standard Linux commands? (in zsh)

Categories Q&A, Unix & Linux Tags files, shell, zsh Leave a comment

How to read an IP address backwards?

August 10, 2022 by Magenaut

If we have this string (IP address): 192.168.1.1

Categories Q&A, Unix & Linux Tags shell, text-processing Leave a comment

recovering deleted file held open by apache?

August 10, 2022 by Magenaut

Suppose an apache log file gets deleted but it’s held open by apache; then this is what I am doing:

Categories Q&A, Unix & Linux Tags apache-httpd, data-recovery, linux, logs, shell Leave a comment

sh startup files over ssh

August 10, 2022 by Magenaut

I have some important commands I need to execute before any sh shell starts. This is required for passing SSH commands in the SSH command (ssh host somecommand) and other programs that run commands.

Categories Q&A, Unix & Linux Tags bash, profile, shell, ssh Leave a comment

How can I time a pipe?

August 10, 2022 by Magenaut

I want to time a command which consists of two separate commands with one piping output to another. For example, consider the two scripts below:

Categories Q&A, Unix & Linux Tags bash, pipe, shell, time Leave a comment

How does lookup in $PATH work under the hood?

August 10, 2022 by Magenaut

There’re way too many articles/resources on the web that teaches people HOW to set the environment variable PATH so that they can use the short hand of java or python etc instead of the absolute path in command line interface.

Categories Q&A, Unix & Linux Tags path, shell Leave a comment

Why is the array empty after the while loop?

August 10, 2022 by Magenaut

I try to initialize an array in bash-4.2 next way: ring=() ls -las | tail -n +4 | while read line > do > ring+=("$line") > echo ${ring[-1]} > done 3924 -rw-r–r– 1 username group 4015716 Mar 23 15:14 script.jar 4 -rw-r–r– 1 username group 9 Feb 29 12:40 rec.lst 5541 -rw-r–r– 1 username group … Read more

Categories Q&A, Unix & Linux Tags bash, pipe, shell, variable Leave a comment

Which shells support ANSI-C quoting? e.g. $’string’

August 10, 2022 by Magenaut

I have a shell script that uses the following to print a green checkmark in its output:

Categories Q&A, Unix & Linux Tags escape-characters, portability, quoting, shell Leave a comment

Is field splitting and filename expansion turn off in RHS of variable assignment portable?

August 10, 2022 by Magenaut

In most POSIX compliant shell like bash. ksh, dash, mksh, pdksh, when variable assignment occur, field splitting and filename expansion (and brace expansion if the shell supports) are not performed in RHS of assignment:

Categories Q&A, Unix & Linux Tags posix, shell Leave a comment

Where has the trailing newline char gone from my command substitution?

August 10, 2022 by Magenaut

The following code best describes the situation.  Why is the last line not outputting the trailing newline char?  Each line’s output is shown in the comment.  I’m using GNU bash, version 4.1.5

Categories Q&A, Unix & Linux Tags command-line, command-substitution, shell, text-processing Leave a comment
Older posts
Newer posts
← Previous Page1 … Page11 Page12 Page13 … Page46 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress