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

learn more… | top users | synonyms

1
vote
1answer
113 views

Sorting downloads folder with bash script

I'm writing script for my own needs to sort Downloads folder on my mac in bash. I pass to the function parameters: source directory, destination directory and array of file extensions I want to move. ...
0
votes
1answer
827 views

Using the Linux split command to create N Files

I need to split files into guaranteed number of buckets. The size do not have to be equal. Here is my logic count = wc -l filename split_count = (count)/4 split -l split_count filename core_ ...
2
votes
3answers
4k views

Terminal unzip outside default directory

Using terminal command "unzip" seems to be extremely useful when deploying a CMS to a remote server, since you can transfer a zip and unzip it remotely. However, I cannot find a way to unzip the all ...
0
votes
1answer
364 views

cat file that contains escaped characters to netcat

I'm trying to test a webserver with some HTTP request written in a file. GET / HTTP/1.1\r\n\r\n Right now I'm feeding that file to netcat like this: cat files | nc localhost 80 However, the \r\n ...
1
vote
1answer
665 views

command to change text files encoding

Is there any way to change encoding for a lot of text files using command line (bash interpreter)? To be precise I want to get paths to specific files using path and then change their encoding in ...
1
vote
3answers
143 views

Copying current line from shell in linux

While setting classpaths in the .bashrc, I was wondering if there was a way to copy the current output from the shell for pasting later into some editor. What I am trying to accomplish is as follows: ...
3
votes
4answers
1k views

How to list one file in each subdirectory of root folder?

Apologies if this is trivial- but how do list just one file in each subdirectory of my root folder? Linux terminal or MS DOS syntax doesn't matter. I would guess it would be an ls or dir command with ...
6
votes
3answers
6k views

How can I specify command line arguments using pipes in Linux?

I'm a newbie to shell programming and have no idea how to solve this problem. I just downloaded a file from the Internet to the default directory ~/Downloads. I want to move that file to another ...
1
vote
1answer
1k views

How do I enable CTRL right/right arrow key to move word wise in shell?

I tried all the tips mentioned in this article: http://stackoverflow.com/questions/5029118/bash-ctrl-to-move-cursor-between-words-strings But non work for me... Is there a way to work it out ?
0
votes
0answers
99 views

Script to upload backups to FTP/SFTP server [duplicate]

Possible Duplicate: How can I upload local changed files to an FTP server? I have a script that once a day creates backups for database and files. Now I would like to upload them via FTP ...
0
votes
2answers
87 views

Is there a cursor-based interface to change environment variables?

I often need to change a small part of long environment variable (especially, e.g., paths), and do it either by pasting the thing into an editor and changing it there, or the equivalent. Is there ...
2
votes
1answer
2k views

How do I run a SVN post-commit script as root?

I have a SVN repository server that runs under the repository user, and I want to run a script after every post-commit action. I therefore wrote a shell script that runs from the hook after every ...
2
votes
3answers
946 views

Search for file names of a certain length on Unix

How do I search for all files of a certain length in a directory, in UNIX? For example, how do I search for all files whose names are of length 5 in the directory /blah? I've looked all over and I ...
3
votes
1answer
2k views

How do I get the delete key to work properly

I'm on a linux box: jla@jaspden-desktop$ uname -a Linux jaspden-desktop 2.6.35.13-92.fc14.i686 #1 SMP Sat May 21 17:39:42 UTC 2011 i686 i686 i386 GNU/Linux here, at the command prompt, the ...
39
votes
4answers
48k views

Find out if user name exists

How can I find out, in a shell script, whether a given user name exists on the current system? /etc/passwd and /etc/shadow are incomplete. Consider OS X's Directory Services, or Linux with Likewise ...
1
vote
3answers
2k views

find specific files using “find” command only in top directory

I got one probably silly question: I'm working on remote server under Solaris using ssh and my task is to find specific files in directories matching shell pattern but not go recursively deeper. ...
3
votes
3answers
318 views

What shell allows recalling commands with certain beginning?

Programs like matlab/octave and I'm sure many other ones allow you to start typing a command, and then hit Up to recall the last command that starts with the typed characters. Common linux shell bash ...
0
votes
2answers
365 views

Echo command not displaying

I have a shell script with the following: STATUS=`/home/scripts/200check.sh $RUOK_URL` Inside of 200check.sh I have some echo commands, but these commands are not displayed in the terminal. I guess ...
0
votes
1answer
173 views

Please explain the behaviour of the shell (supposed to be csh)

On my Linux box, echo $SHELL results in /bin/csh. So I assume my default shell is c-shell. I am trying to understand the behavior of a shell script. scenario 1 - script contains - echo $1 $2 $3 echo $...
2
votes
1answer
386 views

Bash: How to chown of two file extensions in one line?

How may i merge these two lines into one line? chown abc:abc *.sh chown abc:abc *.txt Change ownership of two file extensions into one liner.
5
votes
1answer
3k views

How can I catch or stop a Linux shut down from the terminal?

Is there a way to catch or stop a Linux shut down after a reboot, halt or shutdown command has been entered? sudo shutdown -r +10 I should now have 10 minutes before the computer shuts down. If I ...
0
votes
2answers
216 views

gnome terminal moving through folders

I was wondering if there was a way to navigate back to the previous folder after a 'cd'. e.g. ~/ cd /home/ ~/ cd /usr/local/ ~/ want should I write here to return to the home dir (not 'cd /home' ^^) ...
1
vote
2answers
108 views

How to force relative that to be absolute in linux?

I have a third-part software with external configuration that takes "path to file" as input parameter. Unfortunately, this software concatenates path given with some predefined path. For example, it ...
8
votes
2answers
396 views

Is it possible to configure the way bash completes directory names?

I'd like to instruct bash to use a special method to perform completion on certain directory names. For example, bash would call a program of mine to perform completion if a path starts with "$$", and ...
1
vote
1answer
297 views

Shell scripting download and upload backed up files

I have gDisk, I don't know if you have ever used it, it allows you to turn your GMail to a hard disk and host any file on it, I have many GMails that I don't use and I can create many others. To use ...
0
votes
1answer
170 views

Does the non-printing characters escape characters still needed for PS1 definition?

While modifying the definition of my PS1, I saw that "\[" and "\]" markers should be added to help bash to compute the right display lenght. Many exemples on the web do not use them or even mention ...
2
votes
2answers
2k views

Shell Window within Textmate

Is there a TextMate Plugin that provides a simple shell window within the editor window? I use the "Missing Drawer" plugin, which replaces the built-in project drawer, so i guess that it is basically ...
3
votes
3answers
3k views

Terminal strangeness after installing Xcode on Lion

I have a simple custom bash prompt: PS1="\[\e[47;1;30m\]\u@\h [\W] \!\[\e[0;32m\]$\[\e[0m\]" It worked great under Snow Leopard, and worked great in Lion until I installed Xcode. I installed Xcode ...
0
votes
1answer
140 views

How to parse time expressions in shell?

I want to have a shell script with a parameter specifying some time. Is there already an existing way to transform time expressions ala: 1d, 34m, 3s, or 0.456h, or 23ms into lets say just milliseconds,...
6
votes
3answers
1k views

Redirecting output twice

I want to redirect my output twice from a commandline For example: comp.reg $T_GDS_MASTER/bin.new $T_GDS_MASTER/bin.old > $T_GDS/log/comp.reg.out 2>&1 I want that command to also print ...
1
vote
2answers
2k views

Printing Linux command line history without line numbers

How can I print Linux command line history without including the line numbers? I want to send it all to a text file like this: history >> history.txt
1
vote
5answers
39 views

Why does the shell perform pathname expansion for utilities?

This question is a sequel of how does grep work? It seems that the shell does the expansion of *.* to all applicable/available files and provide that to utilities like grep. Why does the shell need ...
0
votes
2answers
2k views

How do I make git use ssh-add (when necessary)?

On Linux (CentOS, in case that matters), I'm having a problem with git commands. git can take advantage of keys loaded into the ssh-agent cache, but if the keys aren't loaded, it doesn't seem to take ...
1
vote
2answers
74 views

Why is the --help switch not working for all commands in OS X?

I am trying to append --help on OSX terminal commands but it seems that this is not the right way to display help tips on a certain command. What is the equivalent way to do this in OSX?
0
votes
4answers
105 views

Unix find command help

Hi can anybody help me with the following line; find . \( -type d ! -name . -prune \) -o -type f -name "*Log*" Basically it should find directories where files with "Log" in their name are present. ...
1
vote
3answers
204 views

How can I determine whether different commands using grep, find and xargs do the same thing?

Do these three commands do the same thing? A command that uses grep. grep "a" -r . A command that uses find. find . -exec grep "a" {} \; A command that uses a grep on a find through xargs. ...
197
votes
12answers
40k views

How can I change to the previous directory instead of going up?

I currently spend a lot of my working hours moving back and forth between two paths which are very far down the tree and divert from each other at root. It strikes me that my life would be a lot ...
3
votes
4answers
4k views

find and replace command for whole directory

Is there any command in Linux which will find a particular word in all the files in a given directory and the folders below and replace it with a new word?
3
votes
1answer
1k views

How do I get context coloring in Mac OS X Terminal?

When I ssh into a remote server from my terminal in Mac OS X Snow Leopard, I get all sorts of great context coloring. It makes it much easier to edit files in vi, gives good contrast when I ls -al, ...
0
votes
2answers
210 views

How can I determine on my system where process substitution creates FIFO files?

I'm writing a C++ application and need to work with process substitution in the Bash shell. I'm trying to find a way to validate the paths passed as arguments to my program, some of which point to ...
0
votes
1answer
7k views

Connect from Linux command line to FTP server with proxy

I want to connect to an FTP server from the Linux command line. The server is configured behind a proxy. If I call: echo $ftp_proxy I get a result like this: abc.def.ghi.jkl:8080 If I call: ...
2
votes
2answers
173 views

kioexec with multiple files

We have two environments here at work, and I access the remote machine over ssh. I can do this: kioexec myeditor fish://me@remotemachine/path/to/file.txt But I'd like to be able to do a diff ...
18
votes
1answer
20k views

du only for directories

In C-Shell, how can I get the same output as du -sh ./* but without listing the files in the root dir, i.e. just a list of subdirectories in ./ and the sizes of all their contents?
3
votes
4answers
1k views

How do I add a job to cron?

So, here's what I did: Logged in as root via Shell Typed crontab -e Typed */30 * * * * /path_to_website/cronjobs/cron.php And now what? How do I save it? I just closed Putty and then logged back ...
3
votes
4answers
842 views

Are there any unix shells that support mouse reporting? [closed]

I am currently using bash on OSX (via iTerm2). Sometimes I have to run programs with a very lengthy set of command line arguments. If I find that I've mistyped, it takes way too long to arrow back to ...
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
539 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?