Questions tagged [unix-shell]
130 questions
2
votes
1 answer
Find all the sym links that point to a particular file
I know that ls -l will give you the "number of links" but I'm looking for a command or combination of commands that will give me a list of all the symbolic links that point to a particular file.

Ollie Saunders
- 121
- 2
2
votes
3 answers
Get results from grep in the order they appear?
I'm trying to grep a log file to only show lines that match a certain session ID. Thus far, it works great. However, when I get the results of my grep command, I'm not getting the entries in the order they appear.
If the log file in the directory…

IVR Avenger
- 325
- 1
- 5
- 16
2
votes
1 answer
How to improve the efficiency of gnu parallel to read from a compressed stream?
Is another question extended from the previous one [1]
I have a compressed file and stream them to feed into a python program, e.g.
bzcat data.bz2 | parallel --no-notice -j16 --pipe python parse.py > result.txt
The parse.py can read from stdin…

Ryan
- 5,831
- 24
- 72
- 91
2
votes
3 answers
Unix Linux directory compare
I have a known good directory structure that I'd like to compare owner/group and permissions against another server and flag any files/folders that need to be changed. Since I wont have access to both servers at once, I'd like to script out the…
RXWatcher
2
votes
3 answers
No shell and launch application on login
I am working on migrating an application from OpenVMS to RedHat Linux 6. The application is a green screen terminal application. The users will log into Linux via SSH and the application should automatically start but they should never have access…

greyfox
- 257
- 1
- 2
- 9
2
votes
2 answers
Rotatelogs rotating log files mid log entry
I have a c++ tool that outputs to STDOUT via printf i.e.
printf ("%s\n", logline);
I then pipe that to rotatelogs i.e.
tool | rotatelogs /tmp/logs/log_%s 60
Everything works great, but rotatelogs will rotate mid line so log file 1 has this…

Brian Haines
- 41
- 2
2
votes
1 answer
How to pipe and echo the result that is being processed?
I'd like to execute this command:
find /apps/ -type f -print0 | grep -z log$ | xargs -0 grep 'this->aForm'
And in parallel, I'd like to see which files are being processed.
How to to this?

Olivier Pons
- 622
- 1
- 5
- 22
2
votes
1 answer
'ls' taking a long time to list 20 subdirectories
I have a directory (my_dir) which has 20 sub directories. Every time I run 'ls' or try to autocomplete a file name in this directory my IO usage goes to 100% and it takes very long time (10 mins) to list 20 sub directories.
Here is some background…

Kan
- 29
- 1
- 4
2
votes
1 answer
How to find a file that contains the specified string in FreeBSD?
I'm searching for the way to find a file that contains specified string text.
It should be fast as possible but its not that important.
I was reading the manual, and I've build something like that: grep my_string * -r and it works at all, but if…

Cyclone
- 260
- 1
- 6
- 20
2
votes
3 answers
putty aborts process while shutting down
I'm newby so the question is simple. After I connected to server via putty I want to execute some command. Suppose that command will be performed for long time (e.g. extracting files from large archive or mysql backup). Is there a way to execute a…

Eugeny89
- 131
- 1
- 5
2
votes
5 answers
Counting number of items in a single-row CSV file?
I have a file containing a long comma-delimited list of numbers, like this:
2,8,42,75,101
What's the simplest command (from a Unix shell) to get the count of numbers in this file? In the example above, that would be 5.

An̲̳̳drew
- 1,265
- 2
- 14
- 19
2
votes
4 answers
Is there an easy way to insert data/time in front of a log file with just shell scripting?
Say I want to monitor memory usage on a java process overnight.
I can do something like
top | grep java > out.log
I will get a log file with a whole bunch of lines.
Is there an easy way to get a data/time inserted in front of each line?

James Dean
- 801
- 1
- 7
- 5
2
votes
2 answers
How to concatenate environment variable paths in a cleaner way in bash?
In order to modify my paths (like LD_LIBRARY_PATH or PYTHONPATH), I first check is the variable exists. If so, I'm concatenating my old value with the new one (separated with a semicolon), else I'm settings my variable to the new…

Charles
- 303
- 1
- 3
- 10
2
votes
1 answer
Picking a single line from a text file by its line number
In a Unix shell, how can I pick a single line from a text file by its line number?
Say I want whatever is at line 3 in animals.txt to be written to stdout (bat bat bat).
monkey monkey monkey
cat cat cat
bat bat bat
horse horse horse
Is there a…

xyz
- 501
- 2
- 7
- 13
2
votes
3 answers
Will uploading modified version of a KSH script affect processes that are currently running the script?
Let say I have a KSH script my_script.ksh that performs complex operations including but not limited to invoking SQLPLUS to manipulate large number (millions) of records in an Oracle database. The script accepts a few parameters that determine which…

Lukman
- 186
- 6