The shell is unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks.
4
votes
1answer
128 views
What is the tool that allows me to specify arbitrary directories using **
I once saw a colleague uses a tool which allows to use ** to represent any directories. For example: if a file called myfile.java sits deep inside:
src/main/com/mycompany/product/store/myfile.java
...
4
votes
5answers
478 views
Multiple ssh sessions in single command
I'm trying to copy a database from one server to another. I tried using the following command and it's getting tied up on entering the ssh passwords. If I put in one server's password, it complains ...
4
votes
4answers
2k views
How to search for a word in entire content of a directory in linux
need to search for something in entire content
I am trying:
find . | xargs grep word
I get error:
xargs: unterminated quote
How to achieve this? Thanks.
4
votes
3answers
231 views
Why do you need the “./” when executing programs in the current directory? [duplicate]
Possible Duplicate:
Why do we use “./” to execute a file?
It seems redundant and gets annoying after a while -- is there a way to change this? If not, can somebody explain the ...
4
votes
3answers
664 views
How to print all printable ASCII chars in CLI?
How can I list all the printable ASCII characters in the terminal?
4
votes
3answers
2k views
Can IFS (Internal Field Separator) function as a single seperator for multiple consecutive delim chars?
Parsing an array using IFS with non-whites space values creates empty elements.
Even using tr -s to shrink multiple delims to a single delim isn't enough.
An example may explain the issue more ...
3
votes
5answers
461 views
How do I perform an action on all files with a specific extension in subfolders in an elegant way?
My current best bet is:
for i in $(find . -name *.jpg); do echo $i; done
Problem: does not handle spaces in filenames.
Note: I would also love a graphical way of doing this, such as the "tree" ...
3
votes
2answers
341 views
What is the best way to find a list of several strings within a large text file
The short, general question is: In Unix/Linux, what is the best way to find a list of several (about 150) strings within a large text file?
I am asking this to all Unix/Linux experts as a general ...
3
votes
4answers
212 views
Change working directory of 2 terminals at once
I've typically have gnome-terminal open with ~8 tabs, using 2 consecutive tabs for the same task (one has emacs, the other is used to do git checkins and unittest runs and so).
When changing tasks, I ...
3
votes
2answers
286 views
How to skip file in sed if it contains regex?
I currently use the following simplified command to remove trailing whitespace and add a newline at end of file where needed:
find . -type f -exec sed -i -e 's/[ \t]\+\(\r\?\)$/\1/;$a\' {} \+
As ...
3
votes
2answers
406 views
Zsh — more intelligent autocorrection
Is it possible to make Zsh stop trying to correct arguments that are not meant to be files with files from the current directory without turning off correction completely or limiting it to setopt ...
3
votes
1answer
1k views
Changing the default shell without chsh or administrator priviledges
I saw the following snippet in this thread: How to change from csh to bash as default shell
sleep 2
if (-x /usr/local/bin/bash) then
exec /bin/sh -c '. ~/.profile; exec /usr/local/bin/bash'
endif
...
3
votes
1answer
274 views
Background task finished notification syntax
Last night, before abandoning my computer for the evening, I started a bunch of compiler jobs so they'd be ready in the morning, using make -f alpha.mak &>alpha.out &. When I came back and ...
3
votes
2answers
2k views
su vs su - (on Debian): why is PATH the same?
I know what should be the difference between su and su -, but in my system (debian testing) for example PATH is the same:
[root]# su
[root]# echo $PATH
...
3
votes
3answers
162 views
is the behaviour of .* to include . and .. defined in LSB or POSIX or some other specification?
as title: is the behaviour of .* to include . and .. defined in LSB or POSIX or some other specification?
2
votes
2answers
72 views
Use a parameter in a command argument
I run a find command to search files with a name containing perl:
find /tmp -name '*perl*'
/tmp/perl.pl
/tmp/run-perl-stage.pl
But when I set the perl name in a variable PARAMETER and run the find ...
2
votes
2answers
183 views
Piping paths with different types of quotes for slash substitution
I would like to use sed to convert a path with backslashes to the same path with forward slashes:
E.g.
I would like to pipe \\path\to\file\ and obtain /path/to/file
None of the following commands ...
2
votes
2answers
341 views
Remove 50GB oldest files in busybox when used capacity reaches 95%
Ok i have requested a code here but initial i didn't ask to make it busybox compatible. My bad. I'm new to linux and coding.
The code needs to do the following:
Delete 50GB of oldest data (dir ...
2
votes
2answers
382 views
When sh is a symlink to bash or dash, bash limits itself to POSIX-compliance, so it should be 100% compatible with sh?
From Difference between bash and sh:
ABck to the question: If you have /bin/sh as a link to bash, then bash will not behave the same when called as /bin/sh as it does when called as /bin/bash. ...
2
votes
4answers
508 views
Make directory copies using find
I have a directory with a bunch of subdirectories in it. Thus
/usr/local/src/ccl/ccl-1.8/x86-headers$ ls
elf gl gmp gnome2 gtk2 jni libc
Each of these directories has a further subdirectory C ...
2
votes
1answer
139 views
Why doesn't dzen2 work when invoked via at?
dzen2 is a notification utility of sorts. This command will make a notification that says "Hi" appear on the screen:
echo Hi | dzen2 -p
Debian's at is a utility that schedules events to occur in ...
2
votes
4answers
4k views
How to find the total number of occurrences of text and files with find command
I am trying to run the find command to find the total number of occurrences of a particular text string and also the number of files which has this text string.
What I have right now is this command.
...
2
votes
1answer
632 views
skype not found on Oneiric 64, but it is right there [duplicate]
Possible Duplicate:
Can't execute some binaries in chroot environment (zsh: Not found)
I have something weird here. Cannot find a file although it is right there.
$ skype
command not ...
2
votes
2answers
617 views
Issues of using sort and comm
I was trying to find the intersection of two plain data files, and found from a previous post that it can be done through
comm -12 <(sort test1.list) < (sort test2.list)
It seems to me that ...
2
votes
3answers
251 views
Returning only the portion of a line after a matching pattern
I have a file (file_name) which contains exactly one occurance of the string Result:, at the start of a line. I want to print all the characters after the string Result: in that line until I encounter ...
2
votes
4answers
288 views
different shell for root and non-root user
When I ssh as root, my shell is bash, but when it's a non-root user it is sh. How can I make them both to use bash?
This actually goes against the logic in this question: Why root's default shell is ...
2
votes
4answers
2k views
executing a sh script from the cron
I have a test.sh script
#!/bin/sh
php /home/v/file.php
sh /root/x/some.sh
when I execute the file as root from command line it works.
sh /home/v/test.sh
when I set it to crontab -e (is the root ...
2
votes
0answers
296 views
How can I check which shell I am currently using? [duplicate]
Possible Duplicate:
How to test what shell I am using in a terminal?
An echo $SHELL will only display the value of the SHELL variable which would indicate the default shell on the system.
...
2
votes
3answers
933 views
how to pass the result of `find` as a list of files?
The situation is, I have an MP3 player mpg321 that accepts a list of files as argument. I keep my music in a directory named "music", in which there are a few more directories. I just want to play all ...
1
vote
1answer
62 views
Nested read fails
I have a list of filenames in a file and want to do let the user decide what to do with each. In bash, iterating over filenames is not trivial in itself, so I followed this answer:
#!/bin/bash
while ...
1
vote
2answers
647 views
How to pass data outside process for zenity progress?
Usually this would be a question about how to pass data from a subprocess to a main process, but maybe zenity has some extra quirks so please focus on zenity.
Example:
#!/bin/sh
(
echo "10" ; sleep ...
1
vote
3answers
165 views
Returning a portion of a line matching a pattern
I have a file (file_name) which contains exactly one occurrance of the string "Result: " at the start of a line. I want to print all the characters after the string "Result: " in that line until I ...
1
vote
1answer
535 views
pass 1 environment variable using sudo
Is this a correct way for passing an environment variable in sudo ?
sudo -u www-data -b env FOOBAR="foobar" /home/user/folder/daemon
1
vote
1answer
293 views
Which process/program create/write the file which I/O is redirected to?
When learning SELinux, I executed semanage fcontext -l > fcontext.txt under /root directory to dump massive fcontext information to a file. The funny result is: fcontext.txt was created, but the ...
0
votes
2answers
153 views
Why screen is not splitting my GNOME terminal?
I am working in a remote Linux box using VNC.I have a single terminal with lots of tabs opened in my system. How can I split them using the screen utility? Does the screen utility work with already ...
0
votes
2answers
1k views
Shell script to increment count of entries
I want a script which increments the count when the script runs. Basically I want to send an email notification when I find 10 devices down from the same country and scripts run after every down ...
0
votes
1answer
542 views
Looping over directory entries in bash and saving to an array
(See update at the foot of the question).
This is a followup question to "Make directory copies using
find".
This question involved manipulating a bunch of directories, This got
too complicated to ...
0
votes
2answers
434 views
shell script to execute in root mode
I need execute script that have commands which should be run in root mode.
If I put sudo before command then when I run script I see permission denied ( I don't have a chance to write password).
If I ...
0
votes
3answers
501 views
What is the purpose of -e in sed command?
I can't find any documentation about the sed -e switch, for simple replace, do I need it?
e.g.
sed 's/foo/bar/'
VS
sed -e 's/foo/bar/'
0
votes
1answer
296 views
POSIX and Bash, sh shorthand, for compound if statement
I prefer to do my sh commands in shorthand, And I prefer to be in POSIX. Truthfully, if the script can run on Dash, that is good enough. Which means using the test command [, not the extended [[.
I ...
-1
votes
2answers
173 views
source script as command [closed]
For some reason (?), often when I write scripts nowadays they do not work, or work only in part, and then I try with . or source and they work perfectly. I'm unsure what is causing this as the scripts ...

