Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.
0
votes
0answers
12 views
How to implement dynamic bash auto completion
I have made a script that lists available projects. You can start a project by entering script start <project>.
Now it would be great to enable autocompletion, so if you're entering start ...
0
votes
2answers
26 views
Linux command to display the contents of a given file byte by byte with the character and its numerical representation displayed for each byte
I am looking for the Linux command and option combination to display the contents of a given file byte by byte with the character and its numerical representation.
I was under the impression that in ...
0
votes
1answer
30 views
Could someone tell me what's wrong with this unix script? [on hold]
What's wrong with this script? I was trying out substitution in Bash Shell, but got an error in the 2nd line, "command not found".
Date = 'date'
echo "Date is $Date"
1
vote
1answer
29 views
Expect Script for Command Line [on hold]
I am writing a script that will allow a Linux admin to quickly change passwords of its users.
#!/usr/bin/expect
# Check password for strength
# ----------------------------------------------
read -p ...
3
votes
2answers
22 views
Alternating a long running task to pause/run to reduce cpu
I have large file I need to mv and even with nice -n19 it seems to affect the server performance.
I think an option would be to run the process in "chunks" whereby I run the command for a few ...
1
vote
1answer
14 views
Storing integer values from string in rrd
I want to collect stats from my DSL modem every 10 minutes. According to lots of websites it's best to use rrd for this. My modem(TD-W8968) struggles with SNMP so I've made an expect script to pull ...
2
votes
6answers
50 views
Rename first part of multiple files with mv
In a directory there are these files and more:
file1.txt
file1.html
file1.pdf
...
Every file1 should be replaced with newfile:
newfile.txt
newfile.html
newfile.pdf
...
I've tried:
for f in ...
0
votes
1answer
16 views
Deleted all files in dir, except ones within a json file [duplicate]
I have a static assets server with 1 million+ images sitting in a folder, most of them I don't need anymore.
I have a list of the filenames I do still need in a .json file.
How in bash can I delete ...
0
votes
1answer
31 views
Remote execution of a file is not working
I'm trying to execute a local file (here /tmp/cmd) on a remote machine (slc05bkt) using SSH. Here's the command I'm trying from a script file:
cmd="ssh -v ssuthari@slc05bkt \"bash -l -s\" < ...
0
votes
3answers
35 views
Shell Script to change locale has no effect
I wrote a simple script to switch my locale.
If I write each line in the console and execute it, it works without any problem or if I put it in .bashrc.
However when I execute the script either with ...
-1
votes
1answer
28 views
error while changing directory using crontab [on hold]
This is my script I am trying to rename the files in folder.
rename1.sh
----------
#!/bin/bash
cd /home/lanein1/WestonIN7pm/"$(date +%Y-%m-%d)" && rename s/WestonIN/WestonIN7pm/ *.jpg
cd ...
3
votes
4answers
171 views
Help with bash script
I am teaching myself bash scripting with the book 'Learning the Bash Shell' by Newbam. I'm getting on OK with the book, but am a bit confused by the following script. It is a script which uses a for ...
1
vote
1answer
42 views
Pass list of directories (that contain whitespaces) to a command in a script
For example, I want to execute the following within a shell script:
tar cvpzf /destination/backup.tgz /directory\ one /directory\ two
I wish to assign the list of paths (with whitespaces in them) ...
0
votes
1answer
58 views
+50
Start new bash session background
Is it possible to create a command called new_bash that allows me to do the following?
new_bash alias test="ls"
new bash alias new_command="ls"
new_bash test
file1
new_bash new_command
file1
6
votes
1answer
48 views
How to revert from searching to original command
Following the instructions here, I edited by .bash_profile to enable the up and down arrows to autocomplete what I have typed in the shell based on previous commands.
I added to my .bash_profile:
# ...
0
votes
1answer
21 views
safe way to redirect some output using exec
I have a script that is rather "noisy". I've been asked to clean up the output so that most of the script's output goes to a log file, and the user just sees the start-up message, and the message when ...
4
votes
3answers
83 views
I have accidentally broken /bin/bash
I just started using Linux. I'm using Ubuntu and I think I made a very grave mistake. I made a script and by some stupid sense I decided to move it to my /bin folder, but I accidentally typed
mv ...
1
vote
0answers
12 views
AFP share with local Unix users
I have a Solaris server on which I have a AFP share. I connect from a Mac client to that AFP share with local users from the Solaris server.
So let's say I connect to the share with the Alice user. ...
0
votes
1answer
22 views
How to create a custom command in Linux for a wine pdf application?
I'm using Debian GNU/Linux 7.8 and would like to have PDFXCview.exe as the standard application to open pdfs. Opening a pdf using a small executable file including
#!/bin/bash
wine ...
0
votes
3answers
111 views
How would an administrator of a system prevent himself access to a file for 24 hours?
How would a single administrator go about locking himself out of a file for 24 hours?
By "lock" I mean prevent access.
I have removed the 'rules' placed on the original post, as it is clear that the ...
20
votes
6answers
2k views
Why does [A-Z] match lowercase letters in bash?
In all shells I am aware of, rm [A-Z]* removes all files that start with an uppercase letter, but with bash this removes all files that start with a letter.
As this problem exists on Linux and ...
0
votes
1answer
38 views
What means echo“{@@##}”?
We got a script that we need to understand, and at some point, we got this syntax:
if [ "$PASS_CHAINE" = "TRUE" ]
then echo "Launching DEGAGEMENT" | SLog
cd $INTERFACE_D/bin_cm/deg
...
1
vote
1answer
23 views
OSX: Delete all matching certificates by command-line
Using shell script to delete all matching certificates.
I found a list of certificates using:
security find-certificate -c "certificatename" -a -Z|grep SHA-1|awk '{ print $NF }'
Output is like ...
0
votes
2answers
11 views
Bash parameter expanstion to remove tabs
I've got such a line in script:
TATVAR=$(echo $PARAMVAR|sed -e 's/^[ \t]*//')
I'd like to shrink this to not to execute additional program (sed), shellcheck suggested to me that i should use:
...
6
votes
3answers
71 views
tell if last command was empty in PROMPT_COMMAND
In bash, from inside PROMPT_COMMAND, is there a way to tell if the user just hit 'return' and didn't enter a command?
-2
votes
1answer
36 views
Restrict bash command for specific user [on hold]
I just searched on this page, but the answer does not meet my idea. My idea is when user called Bob access ssh and run a command, for example sudo apt-get update, then the bash sheell will respond ...
0
votes
1answer
22 views
Queue up multiple videos from Bash Script
-Skip to bold to skip the fluff -
I'm new to ubuntu, so still learning the ropes of how bash scripting goes. I've got this code I've been working on, which works great. (side question - can I ...
3
votes
1answer
30 views
chkconfig does not support my script
I have looked and looked and none of the threads I have found are helping.
We have a tomcat startup script that we modified slightly for our needs. It works fine on Centos / redhat 6 boxes, but does ...
1
vote
1answer
32 views
Provide three argument to one option using getopts in bash
I am trying to process a command line using getopts in bash. I have to pass three arguments after -w option. For example, -w 1 do loop. It should print one line before and after each line from loop ...
-1
votes
0answers
27 views
how to move directories by date to cooresponding monthly directoires
using bash, how would one move directories with a common name, by create date to a monthly corresponding directory without calling out the source specific create date?
#!/usr/bin/bash
$SourceDir ...
0
votes
1answer
69 views
Why is sed coming back with “unterminated `s' command”?
So I have a Bash script which looks like this:
#!/bin/bash
extentemplate="
exten => `$prevchannel`,n,Queue(`$prevchannelname`)\
exten => `$prevchannel`,n,Hangup()\
\
;`$channelname`\
exten ...
8
votes
4answers
657 views
bash loop with 0.02 increment
I want to make a for loop in bash with 0.02 as increments
I tried
for ((i=4.00;i<5.42;i+=0.02))
do
commands
done
but it didn't work.
I appreciate if you help me out.
2
votes
0answers
53 views
Why does this pipe not end when the las process dies (zombie)?
I have a script run and monitored by svscan/supervise. When the last
luces-hf/run:
#!/bin/bash
set -v
export http_proxy=[redacted]
curl -N -s https://[redacted] |\
grep --line-buffered "event" | ...
-1
votes
0answers
42 views
How can I make a Linux system output a bell sound when no packet is received before the next packet is transmitted with the ping command?
This is easy enough on OS X. I just use ping -A example.com and it works just fine. (Note the capital "A".) But it doesn't work like that on Linux. On Linux, the manual page reads as follows:
...
0
votes
1answer
14 views
How to create a module on a CentOS cluster [closed]
I would like to create a module on a CentOS 6 cluster (e.g. module load gcc-4.7.2). Basically, I have no clue how modules work. Are there any good tutorials illustrating this or could someone ...
0
votes
0answers
27 views
shell script in doing operation for 2 folder tree [duplicate]
I have a directory looks like:
dhcp-18-189-47-44:CE-06-new-stuctures_backup wenxuanhuang$ ls
DFT-00001 DFT-00004 DFT-00007 DFT-00010 DFT-00013 DFT-00016 DFT-00019 DFT-00022 DFT-00025 DFT-00028 ...
1
vote
3answers
38 views
Read cells in csv file
I have this table of numbers saved in csv file format as follow:
5, 6, 9, 5,
2, 8, 1, 1,
1, 2, 3, 6,
. . . . .
. . . . .
. . . . .
. . . . .
Every row in this table describe a ...
0
votes
1answer
26 views
extract subfolders outside and rename if necessary
I have a directory looks like:
dhcp-18-189-47-44:CE-06-new-stuctures_backup wenxuanhuang$ ls
DFT-00001 DFT-00004 DFT-00007 DFT-00010 DFT-00013 DFT-00016 DFT-00019 DFT-00022 DFT-00025 DFT-00028 ...
1
vote
1answer
45 views
Can't redirect cut output
When I try to redirect the output of cut it always seems to be empty. If don't redirect it, the output shows in terminal as expected. This is true for OS X 10.10 and Linux 4.1.6.
This works:
...
5
votes
1answer
134 views
How to have type-ahead apply to bash history search (Ctrl-R)?
Context
Typeahead in bash: good
When a bash shell is busy (initializing, running a command), one can type before the next prompt appears.
If the shell has launched a program, that program will ...
2
votes
3answers
33 views
Different 'time's called in similar environments in bash
I was told that people using bash will have to differentiate between the shell-builtin time and /usr/bin/time ( time(1) ). I had to time a program and also had to find ways to automate input, using ...
0
votes
1answer
40 views
Parsing a file to determine what values to use [duplicate]
I have a script and a "config" file that pull variables from. I created the configuration file called config.cfg and used it in my script as such:
#! /bin/bash
if [ -f ./config.cfg ]
then
...
1
vote
4answers
95 views
Show ratio for all availiable resolutions
I tried to get the ratio with this script:
echo "$(xrandr)"|cut -f 4 -d" "|sed 's/x/00 \\\* /g'|while read i; do echo "$i = "$(expr $i); done
but I get errors like
102400 * 768 =
expr: ...
0
votes
0answers
38 views
Passing variables through <<EOF [closed]
fdisk /dev/$ROOTDISK <<PARTCMD
d
$ROOTPARTNUM
n
p
$ROOTPARTNUM
PARTCMD
How can i pass the $ROOTPARTNUM variable?
0
votes
1answer
60 views
How can I merge 3 commands and execute them
I'm try to run a script that figures out the paths based on the hostname:
e.g. if hostname returns computer1 I would like to run path/to/Computer1.py (where path/to is a path that will always be the ...
4
votes
1answer
31 views
How do I abort fc without executing the command?
The command fc will allow visual editing of the previous command. If I change my mind in the editor, how do I stop the command from being executed. In vim, typing q! or q both result in the command ...
0
votes
0answers
17 views
Environment Variable not Exporting [duplicate]
I have this script that I'm writing, basically as my own free dynamic dns system (with a bit more manual-ness at the moment). Here it is:
#!/bin/bash
...
0
votes
1answer
26 views
sort process by cpu usage in cygwin
please help me to sort process by cpu usage in cygwin.
I already tried tasklist but it shows only process by memory usage .
3
votes
2answers
47 views
process Count of each user in ps aux command
How can i create a script to count process run by each user in ps aux. I used this
ps aux | awk '{print $1}' | grep root | wc -l
but it lists count of root user only . I want to list number of ...
1
vote
1answer
28 views
Can I uncompress a zip file containing a disk image and then save that to an SD card all in one step?
I am under the following restrictions:
I have a 1.0 GB .zip file on my computer which contains one file, a disk image of raspbian. When uncompressed, this file is 3.2 GB large and named ...