A shell is software that lets users interact with the operating system, usually by typing at a command-line.

learn more… | top users | synonyms

26
votes
4answers
42k views

How do I find (and kill) process running on a certain port? [duplicate]

Possible Duplicate: Finding the process that is using a certain port in Linux I'm using Ubuntu Linux 11.04. How do I write a shell script expression that will find the process running on port ...
16
votes
1answer
29k views

When creating a symbolic link, how do I troubleshoot 'too many levels of symbolic links'?

I'm trying to create a symbolic link on Ubuntu 10.04 it says: me@laptop:~/PHPUnit$ ls assertions.php LICENSE PHPUnit README.markdown build.xml package.xml phpunit.bat ...
1
vote
1answer
5k views

How do I join 2 variables in a bash script?

I have $db and $DATE set in my bash script, then I need to join them like this: mysqldump --user=usr --password=pss --databases $db | gzip > /backups/sqlNew/$db_$DATE.sql.gz; Unfortunately, that ...
0
votes
2answers
1k views

Truncate all files in a directory after underscore?

I have a directory with a couple thousand images in it. Most of them have sensible filenames like SD-000.tif SD-001.tif BX-000.tif etc... However probably ~25% of them have names like BX-003_old.tif ...
2
votes
1answer
540 views

How to show only the parent folder in the shell prompt

Whenever I go inside a directory in Linux, it shows the file path at prompt like: root@vivek-HP-Pavilion-dv6-Notebook-PC:/var/www/abc/def/ How can I change it to show short names instead?
0
votes
1answer
181 views

Execute command inside first directory of each matched result

I am working at a client who has a project where code is a mixture of different source control systems. So a layout might be like this project/a/.svn /a/subfolder/.svn /b/.hg /c/...
0
votes
2answers
9k views

set -T in bash - what does it do?

What does set -T mean in bash? What does it do? I believe it is related to traps in Unix but I am not sure. I found this: Many of such constructs become more simple if traps would be called ...
8
votes
2answers
4k views

Aliases in subshell / child process

I set up aliases in /etc/profile.d/alias.sh for each login shell. But if I run script.sh, I can't use that alias. How can I set alias even for subshells or child processes ? /etc/profile.d/alias.sh ...
2
votes
0answers
647 views

“Error: AudioQueueStart failed” when running afplay repeatedly

Every time a run in Terminal the command: while :; do afplay "/Users/username/Library/Application Support/Nada/Bell.aif"; sleep 10; done I get the expected result, but after a while the ...
8
votes
1answer
3k views

Runing a command without inheriting parent's environment

Is there a way to run a command "as if" it is in a new login session? I've already tried env -i. However, I don't want to deal with various ENV variables I have to set or unset. I've also tried bash ...
0
votes
2answers
1k views

Unix basic shell script help needed please?

I need some help writing a basic Unix shell script that will run on AIX: Loop that will run a netstat command (netstat -an| grep 16752| grep ESTABLISHED| wc -l) that counts sessions every second and ...
3
votes
2answers
1k views

Count the occurences of a list of words in files

I have a list of words like this, separated by line: Range Balance Total CombinList CombinRow GridKey KeDanJia AddRowNum TopList Keysearch Keysearchtaobao IsearchData IsearchDataSep ... And I have ...
3
votes
1answer
744 views

Windows 7 Primary Folder Icon File?

In Windows XP and earlier, when changing a folder's icon, you can select system32\shell32.dll for a wide selection of built-in windows icons that include most folder types. In Windows 7, you can ...
9
votes
2answers
18k views

How to change proxy setting using Command line in Mac OS?

I am using Mac OS and sometimes some work need to be done using a proxy so I need to change my proxy setting frequently. But changing proxy setting in System Preferences is very messy. Is there a ...
1
vote
2answers
191 views

Change only the user of a file

I have a textfile with name negin.txt in /home and did the following: Right click → Properties → Permissions → Advanced Permissions → Add Entry → Named User user:wwwrun Is ...
4
votes
3answers
7k views

What is the difference between Linux (Ubuntu) and Mac shell commands?

I use Ubuntu at work and a Mac at home. I was trying out some shell commands on my bash terminal on the Mac today but they didn't work. I was told both machines should operate UNIX commands so the ...
4
votes
6answers
2k views

What is the simplest way to remove lines from one file matched with lines from another file?

What's the simplest way to remove lines from one file matched with lines from another file? For example, if I have the following files: file1.csv: u2@domain.com file2.csv: 1,u1@domain.com,...
4
votes
2answers
3k views

Nohup and the difference between logout and exit on a remote shell

I have access to a remote Linux shell for work purposes. I have kept a python script running in the background using nohup. Now, if I want to exit the session, what is the difference between using ...
1
vote
1answer
281 views

Selecting text in a SuSE shell

I have a problem. An application has spat a whole load of log text into a Shell window that needs to be captured. If we could skip passed the "probably shouldn't have had an application output it's ...
0
votes
1answer
195 views

ANSI Colors & Syntax

Is there a mapping of ANSI colors to their syntax in a given shell? For example, in BASH, Blue seems to be Folders and Green seems to be executable files. Does a list exist for what ANSI colors mean ...
11
votes
2answers
57k views

Shell script echo new line to file

I want to echo a new line to a file in between variables in a shell script. Here's my code: var1="Hello" var2="World!" logwrite="$var1 [Here's where I want to insert a new line] $var2 echo "$...
32
votes
5answers
4k views

Does running commands verbosely make them slower?

I've found myself using the -v flag for lots of applications less and less (especially for trivial stuff like tar and cp). However, when I did and I was, say, unzipping a large file, it would take ...
26
votes
6answers
18k views

How can I change all files belonging to one user to another user?

I'm looking for a Linux command that can change ownership of all files belonging to a given user, preferably in a targeted directory, to another specified user. My dream command would look something ...
0
votes
1answer
659 views

How to configure using arrow key to repeat previous shell commands in Minix

I am new to Minix. I'm so impressed by the speed of the system. It looks elegant, I like it. However, I have a question about the shell. In Linux, while using a shell, up and down arrow keys can be ...
1
vote
2answers
384 views

overwriting specific files in a directory tree recursively

I would like to overwrite files in a directory tree, recursively. The ones I would like to overwrite match the filename "x_alpha*.png" and have a size exactly 456 bytes. Is there any way to search ...
0
votes
1answer
223 views

FreeBSD 8.2: Keystrokes in Bash do not show up

I just installed the latest FreeBSD 8.2 distro using Parallels Desktop. Problem: Whatever I type in the Bash/Shell it is not echoed on the screen. It's behaving like a password prompt. As soon I hit ...
4
votes
2answers
1k views

Linux: use find to find text files?

Is there a way to specify to find that I only want text files (and not binary files)? Grep has an option to exclude binary files, so I thought find probably has a similar feature, but I've been unable ...
2
votes
1answer
128 views

PATH not getting included in startup script

I am trying to add the path to the compiler to the $PATH variable. To do this I add the line $ export PATH="$PATH:actualpathhere" to the ~/.bash_profile file. Now when I open another terminal and ...
5
votes
4answers
4k views

UNIX command to dereference a symbolic link?

Is there a UNIX command to dereference a symbolic link? I would like to replace the link by a copy of the file it points to. Example: $ ls a b -> a $ deref b $ ls a b Now, a and b have the ...
1
vote
1answer
165 views

Unix utility to rename file(s) in an editor or inline

I am looking for a unix command-line program for renaming file (or files) visually, in an editor or inline (in the same manner as you rename a file on your desktop). Example. I often need to rename a ...
3
votes
1answer
336 views

Assign control-slash to undo in Terminal.app

I'd like to have the standard Emacs key binding \C-/ for undo in zsh as well. However on Mac using Terminal.app, this keybinding doesn't seem to be transmitted. It will just beep, and cat/read doesn't ...
0
votes
1answer
38 views

How to write code for this archival scenario?

Say after the 1st run, 10 files got created with def user id in abc directory. I tarred the 10 files created by def user id in a tar file with date time stamp extension. Now after the 2nd run, ...
1
vote
1answer
112 views

How to write this script in unix?

How can I write a script for finding the files created by a particular user ID in some locations and tar those files in the same location?
1
vote
0answers
270 views

Using lynx/links/elinks to correctly display a websites Cyrillic characters

Been struggling finding an answer on this topic for a few days now, I"m just curious as to how one would go about forcing either the shell (putty) iself, or the text-browser links to output Cyrillic ...
3
votes
2answers
592 views

sed: Replace an unknown number of patterns on the same line

I'm trying to use sed to search for a certain 'primary' pattern that may exist on several lines, with each primary pattern followed by an --unknown-- number of 'secondary' patterns. The lines ...
1
vote
1answer
185 views

Is it possible to use brace expansion and globbing together?

Say I wanted to copy the .ssh/authorized_keys file in each user's /home directory to /tmp (for whatever reason). I figured I could use globbing and brace expansion to do this quickly, but I ran into ...
0
votes
2answers
437 views

SSH and SSH2 compatibility

I'm trying to set up a passwordless login to the remote host. First of all, I generated a key pair using this command ssh-keygen -t dsa However on the second step when I have to copy public key to ...
2
votes
3answers
425 views

SSH registration script

Could anyone write or help me write a bash script that would do the fallowing: New user connects to my FreeBSD server and log-ins via SSH with certain credentials like 'user registration, pass ...
2
votes
1answer
618 views

What prompt is sh using when you type sh into Terminal?

When using the default PS1 prompt that MAC OS/Terminal comes with, when you type sh you get a new style prompt. station-4:~ user$ sh sh-3.2$ When you export your own PS1, this functionality goes ...
1
vote
1answer
820 views

Character encoding after shebang in shell scripts?

I came across some Ruby scripts on Github. The first line is the normal shebang (#!/usr/bin/ruby), but the second line is the following: # -*- coding: utf-8 -*- I didn't know this method of ...
0
votes
1answer
264 views

How to omit the “.” directory when creating a tar from directory?

To create a backup of entire directory I do: tar -cPzf /home/misha/path/to/tar/tar_name.tar.gz -C /home/misha/path/to/directory/to/backup . In the resulting tar_name.tar.gz beside the files ...
1
vote
2answers
3k views

How to connect to a remote server and run some code on that particular server?

I am implementing an automated backup scheme so I created a shell script which first creates SQL dumps for all MySQL databases, then retrieves all websites from the /var/www directory of a remote ...
1
vote
2answers
133 views

Is there an equivalent of the unix 'look' command on Windows?

I'm looking for an equivalent of the unix look command, which searches a text file for lines beginning with a given prefix. In particular, it has an option for a binary search within a pre-sorted text ...
2
votes
2answers
1k views

I would like to write a shell script/rc file that automates GNU Screen splits and starts programs within them

I would like to automate a scenario when I am working on a rails project, and I think screen is the perfect way to accomplish this without having to drag and drop multiple windows after every startup (...
3
votes
3answers
108 views

Limit permisions for running commands

If a user executes a command like sudo /etc/init.d/apache2 restart I would like to detect that and prevent that script from executing. Can I do this without modifying the apache2 script?
2
votes
1answer
20k views

Call putty/plink to start a remote SSH linux script with user input

Seemingly simple question, which yields slightly undesired results. Execute putty to start a script on a remote linux server which requires user input The remote script does a read -p "Please enter ...
1
vote
5answers
4k views

scp with range of files to be copied to, from, or between different hosts

Working fine: ==> scp my_log-bin.01393[0-9] root@192.168.103.66:/backup/ error - No such file or directory: ==> scp my_log-bin.0139[30-99] root@192.168.103.66:/backup/
0
votes
1answer
1k views

Shell Prompt Colors on Mac OS X

I'm trying to add colors and customize the shell prompt on OS X Lion so I edited .bashrc and I can only see the differences for the root account. So, after I edit the .bashrc with: PS1="[\u][\w] :" ...
5
votes
2answers
2k views

How to install regexp enabled 'rename' on fedora?

I have a batch rename task and I find the 'rename' command in Ubuntu and Fedora is different. In Ubuntu, rename is written in Perl and has regexp support. Is there anyway to install it on Fedora?
8
votes
5answers
3k views

Set $PS1 differently on local computer and in ssh session

I keep my home directory under version control, so that my basic configuration is easily available on any computer. My bash command prompt on my local computer is a complicated, colorful thing that ...