General :: How To Use Foreach In Bash Shell
Mar 25, 2010
I used c-shell previously in unix. One of the useful command I used frequently is foreach.> foreach a (`cat list`)>> echo $a need to use bash shell now instead, and realized that I can't use foreach anymore. The command is not found. Does anyone knows if there is similar command / function in bash shell?
View 9 Replies
ADVERTISEMENT
Mar 14, 2010
I want to change my default shell to tcsh. I used
Code:
usermod -s /bin/tcsh username
command as given at url
But if I open a new shell, it is still a bash shell.
How do I make my default shell as tcsh?
View 6 Replies
View Related
May 11, 2011
So I open firefox from my bash shell with:
Code:
firefox google.ca
it opens firefox, I can browse, etc.
Now if I alt-tab back into my shell, i can't enter any commands in the shell.
I know that i can do this if I close firefox, but I want to keep working in my shell with firefox still open.
Is this possible?
View 6 Replies
View Related
May 4, 2010
Is there a way to define an unlimited history in Bash ?
View 3 Replies
View Related
Aug 18, 2010
Possible Duplicate: Can history files be unified in bash? I have bash running in an ssh session, call this session A. I leave the office, go home, ssh to the same box, call this session B. From session B, I'd like to be able to look at the history of session A.
View 1 Replies
View Related
Oct 4, 2010
How can I get/filter history entries in a specific range?I have a large history file and frequently usehistory | grep somecommandNow, my memory is pretty bad and I also want to see what else I did around the time I entered the command.For now I do this:get match, say 4992 somecommand, then I do history | grep 49[0-9][0-9]this is usually good enough, but I would much rather do it more precisely, that is see commands from 4972 to 5012, that is 20 commands before and 20 after. I am wondering if there is an easier way? I suspect, a custom script is in order, but perhaps someone else has done something similar before.
View 2 Replies
View Related
Oct 26, 2010
Currently the terminal prompt looks like this:[karlis@karlis-desktop current_folder]$How can I minimize the prompt, so that it only shows $ or # without extra info in square brackets?I checked the preferences for the default Gnome-Terminal and Terminator - there are no settings for this. It is pretty hard to use terminal when working in directories with long names.
View 1 Replies
View Related
Apr 12, 2011
I've written a bash shell script (code provided below) that gives the user 4 options. However I'm having a little trouble with the code. Right now when they select option 3, to show the date.It loops over and over again.I have to close the terminal window to stop it because it's an infinite loop. How would I prevent this? Also quit doesn't seem to be working either.
#!/bin/bashe
echo -n "Name please? "
read name
echo "Menu for $name[code]............
View 2 Replies
View Related
Aug 3, 2011
In linux how do I to get the ascii decimal/hex/oct code from a char or a ascii char from a decimal/hex/oct code. I see from the gnu sed user manual that I can use the d# o# x# to specify a character but I am not sure how to use that. If some one has a better way to get the the ` and ' chars through I want to sed with the backtick '`' character and ''' single quote character.
sed '/`/p'
these don't work
sed '/'/p'
sed '/`/p'
View 3 Replies
View Related
Feb 27, 2011
I am working on a simple script that should take two command line arguments, a [number] and a [name]. The first thing the script should do is check to make sure that no more and no less than two command line arguments have been entered when calling the script - an error message should be delivered if the condition is not true.
If two args have been entered, then the message 'processing "scriptname"' should appear, where scriptname is the name of the script being called. The script should then write to the screen "Hi [name]!", and should write this phrase [number] of times. For example, the command $ myscript 2 joe would produce the output: I have read the manual many times looking for examples, and I am very close by virtue of my own efforts. Further, I have searched these forums and others for good examples, which have also gotten me very close. Still my script is not completing the objective, and I am wondering if someone could point me in the right direction. Script:
[Code]...
View 13 Replies
View Related
Apr 30, 2011
i have a script where i need to pass an argument "1234:-)"if i run this as ./shell.sh 1234:-)it wont work because invalid character. i need to handle this with expect utility so if i pass it as ./shell.sh "1234:-)"no issue in bash but expect does not recognize this.
View 7 Replies
View Related
Dec 30, 2010
how do i use bash shell scripts inside php.I am just trying to call a simple cp command using php. Its not doing anything.
View 2 Replies
View Related
Jun 25, 2010
Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?
Example:
Code:
>>> import subprocess
>>> help(subprocess)
...
[pages of stuff to read]
...
I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.
View 4 Replies
View Related
Apr 24, 2010
I just wonder the distinction calling the function between $(one_function) and one_function in bash shell script.
When I set the variable PS1 in ~/.bashrc, I can't invoke the function by one_func
ex:
export PS1="
[e[31m] $(one_func) # it works
export PS1="
[e[31m] one_func # it doesn't work
View 3 Replies
View Related
May 9, 2011
I am wondering is it possible to echo values like below described? The situation is - there are too many "doc" files named like "PLCI507_01234567.doc", and there is a Form in a text file named "form.txt" looks like below:
I am already able to create files in the same format for each documents but now I want all the information in a single form and the form should be updated with file informations ie. file name, created date, md5sum etc.
The updated form.txt should be like below.
View 2 Replies
View Related
Oct 4, 2009
I have a CentOS dedicated server running ProFTP. I have created user accounts which are meant for FTP access only but the users cannot connect to the FTP unless their shell access is /bin/bash
Here is an example line that is outputted when I use this command:
This user can access the FTP fine, but he can also access SSH which I don't want to allow him to do. If I set his shell access to /bin/false then he can't connect to the FTP.
What can I use in instead of /bin/bash to allow FTP but don't allow SSH?
View 2 Replies
View Related
Jun 21, 2010
I have a user that has been used for long time now that runs o C Shell... now there is a need to change it to Bash Shell? Can I cause a problem changing his shell from C to bash? I mean apps or variables?
View 2 Replies
View Related
Jan 21, 2010
I am unable to use clear or cls command on bash shell. I have recently installed Cygwin and am using that for practicing unix commands.
I see that I can use Ctrl + L to clear the screen. I created an alias in my .bashrc to do the same as
alias cls='^L'
This is how i defined other aliases e.g.
And they work. Hence I assume cls will work too but this is what I get when I try to give cls on command prompt. Am i missing something? Is there a way to do this?
Then someone suggested, You cannot alias keystrokes to commands or vice versa. You could just alias cls to an echo command: echo -en "x0c"
And I added the following to .bashrc,
Sourced the .bashrc file. No errors but cls still does not clear the screen. Infact when I typed the echo -en "x0c on command prompt as well, nothing happened. What does this command do?
View 3 Replies
View Related
Mar 15, 2011
I would like to evaluate a postfix string using bash shell script,but I do not know how to start.
View 1 Replies
View Related
Sep 18, 2010
Any one tell me online bash login using putty [ssh port] for practicing a linux.
View 6 Replies
View Related
Jun 4, 2010
I do not know how to write either PYTHON or Bash Shell Scripting. I am to learn one for Linux Administration purpose. Which one will you recommend for a Linux Admin/Eng environment?
View 4 Replies
View Related
Jul 15, 2011
Today I faced a very strange issue while switching to root account in a bash shell.My OS : CentOS-5.1.4
I logged in my system with account name user1 and I open the terminal and below shell opens
[user1@localhost ]$
Now when I type su and want to switch to root account , it fails
[user1@localhost ~]$ su
Password:
su: incorrect password
[user1@localhost ~]$ exit
I know the password is 123 & I m 100% sure .
View 8 Replies
View Related
Aug 10, 2010
I am about to write my first shell script for backing up my server.
These are the steps I have identified so far.
Copy files to be backed up to /srv/backup/ run mysqldump and copy the file to srv/backup/databases run duplicity to backup /srv/backup/* to another folder on my machine
I am writing a bash shell scrip that will be run everyday, and will carry out the three tasks mentioned above.
Note: point 3 (backing up to a local folder) is only a temporary measure - to allow me to understand what I'm doing, since all the tools I am using, are new to me. Once I can backup and restore correctly, I will use duplicity to compress and encrypt the files and upload them offsite.
If my understanding of duplicity is correct (according to the documentation here), the first time I run the script, a FULL backup will be done. Every subsequent backup will then be incremental. I will then force a FULL back on say a weekend.
First things first though - I have a few questions:
I would like to use backup rotation for the 'scheme' described above - I would like some recommendations on what kind/type of rotation to use. Once I have implemented the backup rotation, how can I restore from a particular day back in time (assuming the backup exists of course). ?
I am running Ubuntu 10.0.4
View 1 Replies
View Related
Apr 25, 2011
I know it's possible to change the $ user@hostname colors, but is it possible to color different things? Could I make all numbers/integers a certain color. Or set certain keywords to be bold?
View 1 Replies
View Related
Jun 8, 2011
I named a number of files with spaces in them, and I want to replace the space with "_". However, every time I write a command in the shell with the file name (eg "Spring 2011"), the shell doesn't recognize the file or directory. What can I do about this? Is there any way to use the unicode character for a space?
View 5 Replies
View Related
Apr 28, 2011
I'm trying to be able to Open a text editor without needing an existing file.This is my code:
case $ans in
"Show Today") echo "$(date)";;
"Show Calendar") cal;;
[code]...
View 14 Replies
View Related
Mar 23, 2011
After installing the ATI graphics driver that was suggested under System > Devices, ubuntu required a reboot. now it either hangs on boot, or boots into the Bash shell. I tried the option in the Grub boot llist to boot into recovery mode, and then teh option to fix recent update (or something like that), but it did not help.
Assuming the ATI driver is the problem, how can I back it out?
View 2 Replies
View Related
Aug 4, 2010
there is a folder. Its empty. When every I drag a new file and put into it it echo out "there is file in there" and keep monitoring the folder. How can I do it?
View 7 Replies
View Related
Nov 8, 2010
Cis 140 student.how to use the test command to evaluate whether the shell variable I create contains a referance to the bash shell? and use the echo command to determine the result.
View 1 Replies
View Related
Oct 12, 2010
I'm using timeout core utility in my bash shell script. The problem I'm facing is I want the PID of the command which is supplied to timeout. Let me explain with the code I'm using:
Code:
#!/bin/bash
timeout 120 ./prog1 &
[code]....
View 5 Replies
View Related