I've disabled the toolbar of my console in bash. Apparently there is not short-cut key (hat I know off) to switch the toolbar's visibility. Is there an easy way to get my toolbar back?
I was wondering if there is a way to trace where a command was run from in Linux.
For example, if I call a script, is there any way to trace where it was called from, like started from a program or another bash script.
I would like to change the formatting on my BASH prompt from this:
[email protected]:~/some/very/annoying/long/path$
to something like this:
[email protected]:~/some/very/annoying/long/path
$
The idea is that I would be able to type a reasonably long command on one line without it wrapping to the next line so quickly.
I want to use my bash shell to see the attributes that are shown when you right click on an Application and click Get Info. The specific attributes that I want to know whether or not they are checked is Open in Low Resolution, Prevent App Nap, and Locked.
I looked in the Info.plist file but only generic information about the file was contained here, not which attributes were checked.
Is this information contained in the Applications binary? Where is it?
I use the following entry in ~/.bashrc file to colorize the prompt and display current branch of git repository:
PS1='\[\e[1;32m\]\[\u@\h\]\[\e[m\] \[\w\]\[\e[1;1m\]\[$(__git_ps1 " (%s)")\] \[\e[1;1m\]\[$\] \[\e[m\]'
This works almost fine, except when I use bash history (up arrow key few times), the command line becomes 'outdented' (just the first characters of the prompt remains untouched), and the visible is:
usemmand
when my username is user and the command is command.
In my bash script i want to execute command that will find lines in a file that starts with a keyword which is stored in a variable like this:
keyword="key"
result=(`cat path/to/my/file | grep '^$keyword'`)
I would like to control a bash script like this:
#!/bin/sh
USER1=_parsefromfile_
HOST1=_parsefromfile_
PW1=_parsefromfile_
USER2=_parsefromfile_
HOST2=_parsefromfile_
PW2=_parsefromfile_
imapsync \
--buffersize 8192000 --nosyncacls --subscribe --syncinternaldates --IgnoreSizeErrors \
--host1 $HOST1 --user1 $USER1 --password1 $PW1 --ssl1 --port1 993 --noauthmd5 \
--host2 $HOST2 --user2 $USER2 --password2 $PW2 --ssl2 --port2 993 --noauthmd5 --allowsizemismatch
with parameters from a control file like this:
host1 user1 password1 host2 user2 password2
anotherhost1 anotheruser1 anotherpassword1 anotherhost2 anotheruser2 anotherpassword2
where each line represents one run of the script with the parameters extracted and made into variables.
what would be the most elegant way of doing this?
PAT
I need to copy a website, but I want to exclude specific HTML element IDs and classes in all pages (using a bash script).
I need this because I don't want ads or some other annoying features of some websites.
Hey guy,
I know that you can start a background job with Bash doing foo &. However, the best way I know to put a foreground job to the background is to do Ctrl+z to pause it then bg 1 to resume it in the background.
Is there a faster way? Some Ctrl+Something key combination I'm not aware of?
Thanks!
I'm using Putty Connection Manager which captures CTRL-R key before it can get to my bash shell.
So I was wondering if it is possible to map the reverse-history-search to another shortcut key. Such as CTRL-W or maybe even F1.
Any help would be appreciated.
I am looking to create a cron job that opens a directory loops through all the logs i have created and deletes all lines but keep the last 500 for example.
I was thinking of something along the lines of
tail -n 500 filename filename
Would this work?
I also not sure how to loop through a directory in bash
Thanks in advance.
I need to copy a website, but I want to exclude specific HTML elements by ID or class in all pages (using a bash script).
I need this because I don't want ads or some other annoying features of some websites.
I want to retrieve the cpu usage/free percentage from mpstat output. The bash cut can be used to retrieve such details but i dont know what should be the delimiter viz.
[idlecool@archbitch proc]$ mpstat | grep "all" | cut -d '$x' -f11
what should be $x so that i can skip white spaces and select value corresponding to %idle?
Output of mpstat:
[idlecool@archbitch proc]$ mpstat
Linux 2.6.36-ARCH (archbitch) 01/14/11 _i686_ (2 CPU)
19:58:53 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
19:58:53 all 5.51 0.01 2.96 0.84 0.00 0.01 0.00 0.00 90.66
Here is my original question at StackOverflow.com
This is the script I wrote
#!/usr/bin/env bash
GP=`/usr/bin/which git`
PWD=`pwd`
echo "PATH IS: ${GP}"
echo "PWD IS: ${PWD}"
and output is
PATH IS:
PWD IS: /Users/user/tmp
So the question is how to get which git output? I'm running it on Mac OS X 10.6.2.
I find I frequently use the combination of Suspend (^Z) then send to background (bg) in bash. Ideally I would like an alternate keyboard shortcut that negates the need to follow ^Z with the bg command, and just send the active process straight to background. Does this exist?
Edit: I should have been more specific, but appending & to the command is not sufficient, as they often require interaction (stdin) between launch and backgrounding. So:
launch
interact
background
So, the question pretty much says it all. I'm on Snow Leopard, and I do a lot of web development, particularly in Rails 3 which makes heavy use of the console.
I've seen some notable bloggers etc. mention Zsh as their preference over Bash, but I don't know what difference it would make.
Could anyone give me a good comparison of what difference there is and what might make one prefer one option or the other?
Thanks!
I'm writing a bash script that encrypts the data of a folder or file
#!/bin/bash
file_name=$1
tmp_file=/tmp/tmpfile.tar
# tar compress file
tar -cf $tmp_file $file_name;
# encrypt file
gpg -c $tmp_file
# remove temp file
rm -rf $tmp_file $file_name
# mv encrypted file to orignal place
mv ${tmp_file}.gpg $file_name
but the data will still be recoverable by using photorec or similar methods...
Is there a way to ensure the absolute deletion of the original file in bash?
Thank You
Stefan
I need to have the ability to create user accounts on my Linux ( Fedora 10 ) and automatically assign a password via a bash script ( or otherwise, if need be ).
It's easy to create the user via Bash eg:
[whoever@server ]# /usr/sbin/useradd newuser
But is it possible to assign a password in Bash, something functionally similar to this (but automated):
[whoever@server ]# passwd newuser
Changing password for user testpass.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[whoever@server ]#
I wrote a bash-script to check if a process is running. It doesn't work since the ps command always returns exit code 1. When I run the ps command from the command-line, the $? is correctly set, but within the script it is always 1. Any idea?
#!/bin/bash
SERVICE=$1
ps -a | grep -v grep | grep $1 > /dev/null
result=$?
echo "exit code: ${result}"
if [ "${result}" -eq "0" ] ; then
echo "`date`: $SERVICE service running, everything is fine"
else
echo "`date`: $SERVICE is not running"
fi
Bash version: GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
I am using the following JScript code to search for a string inside a file:
var myFile = aqFile.OpenTextFile(fileToSearchIn, aqFile.faRead, aqFile.ctANSI);
while(!myFile.IsEndOfFile())
{
s = myFile.ReadLine();
if (aqString.Find(s, searchString) != -1)
Log.Checkpoint(searchString + " found.", s);
}
myFile.Close();
This is rather slow. I was thinking about using bash commands in order to speed up the search in file process:
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("C:\\cygwin\\bin\\bash.exe -c 'cat \"" + folderName + "/" + fileName + "\"'");
while (!oExec.StdOut.AtEndOfStream)
Log.Checkpoint(oExec.StdOut.ReadLine());
while (!oExec.StdErr.AtEndOfStream)
Log.Error(oExec.StdErr.ReadLine());
Since every time bash.exe is started a new window opens the searching is not faster than before. Is there a possibility to have the bash run in the background using another switch?
Under Windows 7 I'd like to change the settings for the Git Bash Here shell extension command window, e.g. width, height and font. But when I do this, I get an error "Unable to modify the shortcut".
I can modify the shortcut for Git Bash in the Start menu by using "Run as administrator..." This works, but only for Bash windows opened from the Start menu. It doesn't work for the "Git Bash Here" shell extension and there's no "Run as administrator..." option on right-click context menu.
How do you do it?
Sorry if this seems like a dumb question but I am just learning bash scripting. For a school project we need to code an RTX that runs in Unix. It runs as a process in terminal and takes in user input and then prints it to the screen. I want to write a bash script to test that it can respond to lots of quick user input without overflowing or failing.
My main problem is that once the RTX starts the bash script will stop on that line until the RTX terminates and only then print the loop to the terminal (instead of printing it to the RTX prompt as I intend it to).
I have tried running the RTX in the background but that didn't work. I need to find a way to redirect input to the RTX while it is still running with a bash script. Google searches didn't come up with examples that I understood/could adapt. Any help is appreciated.
#!/bin/bash
# declare STRING variable
STRING="RTX Worked =D"
#Start the rtx in a new process, stuck on this line until rtx terminates.
./main
#Somehow redirect io to the rtx.
for i in `seq 1 100`;
do
echo $i
echo " \n"
done
echo $STRING