Bash is the shell from the GNU project. It is the standard shell on many Linux distributions and often available on other *NIXes.
0
votes
2answers
20 views
need help in making script
I want to automate one task in UNIX and make one script.
There is directory in which everyday 2 files comes and that files come anytime in between 10 pm to 1 am.
file name is ...
0
votes
1answer
9 views
Using Bash to write to a device in /sys?
I have one of these:
Basically, it's a USB device with three LEDs (red, green, and blue).
The Linux kernel has supported this device through the usbled module for quite some time now. However, I ...
7
votes
2answers
88 views
Are quotes needed for local variable assignment?
Can I safely omit quotes on the right side of a local assignment?
function foo {
local myvar=${bar}
stuff()
}
I'm mainly interested in bash, but any info on corner cases in other shells are ...
2
votes
2answers
15 views
find: combining -path and -prune to exclude files and directories
I have a directory /srv/tftp/pxelinux.cfg and a file /etc/mtab. I want to exclude both from find. But whatever I do, either one always is not excluded
find /etc /srv -path /srv/tftp/pxelinux.cfg ...
2
votes
2answers
30 views
Different error messages when using different strings in terminal
When I insert, for example, unix.stackexchange.com followed by Enter in terminal, I get the following error:
unix.stackexchange.com: command not found
This is ok and as I expected. But when I insert ...
0
votes
1answer
56 views
Am I running Bash?
I am using OS X 10.8.5. I am trying to figure out if the terminal is running bash. When I type in the following it says "getent" command not found -- but the error message seems to be coming from ...
4
votes
3answers
66 views
What is the difference between [.]* and '.*' for command 'find -name'?
My goal is to find all files or directories in a filesystem that start with a dot (.), for example .gnupg. So I came up with the command:
find -name '.*'
Checking on the Internet, I saw some hints ...
2
votes
2answers
50 views
Need to get the difference between two time in seconds
The following two variables contain the start time and the end time , need to
get the difference between these two time in seconds
start_time=06:07:25
end_time=07:02:08
Desired Output
diff_time= ...
0
votes
2answers
44 views
Cannot create root jail
I just tried to play around with chroot command only for testing purposes, in order to create a temporary root jail, but I didn't managed to. The platform is CentOS 6.4. and I have done it numerous ...
0
votes
1answer
53 views
What command will generate average lines per minute?
I'd like to know how many average lines are written to a file per minute. Could someone help me with a command or code to generate this number?
3
votes
3answers
47 views
'Binding' Bash Curly Braces
In Bash,
echo a{b,c}d{e,f}
prints
abde abdf acde acdf
The output I'd like to see is
abde acdf
In other words, given N parameters, I'd like Bash to use the ith parameter within ...
0
votes
0answers
22 views
linux cross compile [on hold]
im im cross compiling the simple c program through linux to arm
the compilation is-
export CROSS_COMPILE=~/gcc-linaro/usr/bin/arm-linux-gnueabi-${CROSS_COMPILE}gcc -o hello_world hello_world.c ...
0
votes
0answers
25 views
How to use grep command to find the matching pattern and some more characters? [duplicate]
I have a compressed JS code and I want to find a pattern, but since the file is compresses, it has only a line, and the match pattern is all the file. The output is too much large.
grep -r ...
2
votes
4answers
105 views
How to catch an error in a linux bash script?
I made the following script:
# !/bin/bash
# OUTPUT-COLORING
red='\e[0;31m'
green='\e[0;32m'
NC='\e[0m' # No Color
# FUNCTIONS
# directoryExists - Does the directory exist?
function directoryExists ...
17
votes
9answers
660 views
for vs find in bash
When looping through files there are two ways:
1. use a for-loop
for f in *; do
echo "$f"
done
2. use find
find * -prune | while read f; do
echo "$f"
done
Assuming these two loops will ...