I’m using Bash on Debian GNU/Linux 6.0. Is it possible to get the file creation date/time? Not the modification date/time. ls -lh a.txt and stat -c %y a.txt both only give the modification time. Answer Unfortunately your quest won’t be possible in general, as there are only 3 distinct time values stored for each of your files as defined by
Tag: bash
Parse ps’ “etime” output and convert it into seconds
These are possible output formats for ps h -eo etime How to parse them into seconds? Please assume at least 3 digits for the days part as I don’t know how long it can be. The output will be egreped to one only line so no need for a loop. Answer With awk: Run with : Output: And finally, if
Bash Shell Script – Check for a flag and grab its value
I am trying to make a shell script which is designed to be run like this: Firstly, in my script I want to check to see if the script has been run with the -t flag. For example if it has been run without the flag like this I want it to error: Secondly, assuming there is a -t flag,
In reverse-i-search (Ctrl+R ) ,Any method to switch between similar commands in history
I think an example will be good to understand my question. Assume that is the order of commands in history. If I am doing Ctrl+R and type scp it will show the last executed scp command ( ie the line ending with ‘tested’) . But I want to locate the scp command ending with ‘important’. So is there any way
Linux shell script to find and rename files to remove suffix?
I have some files named like this: file1.c.keep.apple file2.c.keep.apple I am trying to write a shell script so that I pass in the suffix as an argument (in this case, apple) and it will rename all of the files removing the .keep.apple. Example execution: script.sh apple results in the files above being renamed to file1.c file2.c So far, I have
Bash terminal and color output [closed]
Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 10 years ago. Improve this question I have a shell with colors enabled: somefile contains escape characters for coloring. Now I want to output somefile to the terminal with its coloring. I tried: But
Bash while read loop extremely slow compared to cat, why?
A simple test script here: When I do cat my450klinefile.txt | myscript the CPU locks up at 100% and it can process about 1000 lines a second. About 5 minutes to process what cat my450klinefile.txt >/dev/null does in half a second. Is there a more efficient way to do essentially this. I just need to read a line from stdin,
Use wc on all subdirectories to count the sum of lines
How can I count all lines of all files in all subdirectories with wc? man wc suggests wc -l –files0-from=-, but I do not know how to generate the list of all files as NUL-terminated names did not work. Answer You probably want this: If you only want the total number of lines, you could use
Bash script error. Syntax error near unexpected token
I’m trying to work through a script to email me a notification if the load is too high on our server. I found a good one but it’s giving me and error when I run it, and I can’t see why. Running the code below gives the error: line 13: syntax error near unexpected token `fi’ I thought I had
Sort files numerically in bash
I need to sort .flv files numerically and i was able to do it with the following command: but with many files(hundreds) it’s not sorting correctly. but the strange this is, if i’m ruining the command without “*.flv” it’s working. i could use just ls but i have other file types in the folder. what i’ve tried so far: Answer