0
votes
0answers
19 views

How can I get “ldd” on Mac OS X?

"ldd" is a Unix/Linux utility that allows you to determine "dylib" references within an executable file, typically created by gcc or g++. There is an Apple equivalent called "otool" that uses a -L ...
0
votes
2answers
46 views

How to delete half of the files in a directory?

A directory has files with names ending 001 to 100. How can you delete 2,4,6,8...100. And can that be written as a script. As soon as the directory becomes week old, this has to run. And after a month ...
1
vote
2answers
31 views

Compare two files and output the differences

I am aware of diff and using loops but I just cant seem to really get what I need with diff. I'm basically looking to compare two files (file2.txt and file2.txt) and just get the output of what is ...
0
votes
1answer
29 views

Linux bash iterating and Break

I have two server groups SERVERS_CA AND SERVERS_NY. I will have a array something like SERVERGROUP=(CA NY) CA and NY will have set of servers in arrays like CA=(ca126 ca546 ca 642) NY=(ny112 ny113 ...
0
votes
1answer
37 views

Memory usage of a process in a shell script

I want to find out the memory usage of a process in a shell script.I tried to use this piece of code : while[process] do if [ -e /proc/$pidno/statm ]; then m=`awk '{OFS="\t";print ...
0
votes
2answers
41 views

Delete Directories that Contain Specified File in Mac OS X

How do I delete a folder that contains a file or folder with a specific name? E.g. I want to delete all folders that contain the file "things.txt": /dirA/ /dirB/things.txt /dirC/ /dirD/things.txt ...
3
votes
3answers
53 views

Sed replace only in even numbered lines of a file when replace commands are written in a file

I have all the replace commands in a file (say replace.sed) and i use it with -f flag of sed (sed -f replace.sed InputFile). But now i ran into a condition where i need to apply these replace rules ...
2
votes
1answer
102 views

wc / cat command not found

I'm trying to run some simple bash script which uses wc and cat commands. The script fails with this: wc: command not found or this (after I commented string which uses wc): cat: command not found ...
0
votes
1answer
40 views

tar -czvf with no output file

Say you run tar -czvf some_folder_here and don't actually specify an output file, like tar -czvf some_output_file.tar some_folder_here. Where does the file go? I just ran this by accident, and the ...
1
vote
2answers
45 views

Retrieve secure copy in UNIX?

Is there a way to retrieve a secure copy in UNIX? Why would I need to do this? Because I can login to a remote machine from my local machine, but not the other way around. So I need to retrieve a ...
-1
votes
1answer
39 views

how to retrieve following error when i execute shell script

I have one script to log into remote server.But i tried to Execute the script some error occur. Logs: My script: #!/bin/bash S1=$(ssh -t selvam-odc-shell1 "users | wc -w ") S2=$(ssh -t ...
0
votes
0answers
21 views

-t, -T and/or -t -t options for ssh are not stopping stty errors

I've googled this error (which is a pretty common error) ad nauseam, but none of the solutions are working. Disabling pseudo-tty allocation nor forcing pseudo-tty allocation work for me. I always ...
0
votes
0answers
27 views

How to query mssql db from bash on subsystem for unix

I have a script that is used to query a database and use the result set for further processing. This is a shell script that runs on bash. But the bash used is the one shipped in subsystem for Unix for ...
0
votes
1answer
14 views

Move child folders into a different folder

I am new to UNIX, and I am trying to write a shell script that would move all folders that are older than a day in log archive directory into another folder. Below is the command I am using for doing ...
1
vote
2answers
29 views

batch rename multiple mp3's stripping leading digits

Hi could anyone help me? Im trying to strip leading digits from multiple mp3 files so "01 some_file.mp3" would become "some_file.mp3" if any one could show me how to doit with zmv that would be great
0
votes
2answers
48 views

Is there a unix command to output time elapsed during a command?

I love using time to find out how long a command took to execute but when dealing with commands that execute sub-commands internally (and provide output that allows you to tell when each of those ...
0
votes
1answer
94 views

Delete file if number in filename less than xxxx

I have thousands files in format randomstring_XXXXXXXX.jpg where 'xxx' is unixtime (1388415305). Now I need to delete all files older than some (unixtime) date. Does anyone have a solution for this?
0
votes
1answer
41 views

Unix : Avail Space of File mounts

Problem Statement This is regarding the space usage of file system mounted in Unix box df -h -> Gives the total usage/avail/used/used% of all mounts in unix server Is there any other way to ...
0
votes
1answer
96 views

email command not working in UNIX Linux

I tried with 2 email UNIX commands mail and mutt from my Red Hat Linux box. It's not sending any mails to the email id I specified. echo "My message" | mail -s subject "test email" <my valid ...
1
vote
2answers
229 views

Pipe output from two commands into one

Is it possible in unix/bash to pipe output from two commands into another? I tried running the following command, which successfully ran both commands, but the first was piped to stdout and the ...
1
vote
1answer
43 views

Move Files having No Extension

I have 5 files in a directory log.txt abc.pdf def.ppt 1CC 1DD Now I want to Move files having no extension i.e 1CC and 1DD to a another directory i.e tree. whenever i am manually using command it ...
1
vote
1answer
47 views

Find last 24 hours executed commands per each user in bash

How can I find last 24 hours executed commands per each user and mail them the result? I have Ubuntu GNU/Linux. I find out that I need a package named 'acct'. I have already installed and enabled that ...
0
votes
2answers
27 views

File sorting confusion

Q1. I have a command and I'm confused why it's sorting the filesizes by Kilobytes then Megabytes? $ find ~ -maxdepth 1 -size +1024c -type f -exec du -h {} \; | sort -nr 80K /home/sl6/S3401636/Lab 4- ...
0
votes
0answers
133 views

Kali Linux: Renaming files in bin

I'm just curious. I want to rename files in /bin such as - ls --> als //after I change it, the ls command no longer works and I have to use als instead - adduser --> aadduser - chmod --> achmod so I ...
0
votes
1answer
43 views

find files older than create its parent folder in a directory and move them there

I've been trying to create a bash script that does the following. Use the find command to search for files older than 7 days (find . -type f -mtime +7 ! -iname '.*', take the parent directory(of the ...
0
votes
1answer
116 views

Why do python's os.stat and du and ls not agree on block size?

While writing a simple function that computes the quantity of blocks consumed in a directory, I checked with du to see that I was getting the same answers. Why do ls and du say this file occupies ...
0
votes
2answers
81 views

cat wc -l count lines line with defined line endings (e.g Mac OS X specific)

As any command-line user I sometimes want to count lines in text file with well known command: cat some_text_file | wc -l I face the problem on Mac OS X, which as far I have it studied is connected ...
1
vote
1answer
658 views

Does rsync delete files, folders at destination by default?

Files Suppose that /foo/src contains only A.c and that /foo/dest contains both A.c and B.c. And suppose I run the following command: rsync /foo/src/ /foo/dest Will rsync erase B.c? Folders Now ...
0
votes
1answer
45 views

Concatenate header of one file with tail of another

I have a large gzipped mysqldump file which contains some table definitions and then many insert statements. I'd like to edit the table definitions but leave the insert statements alone. The file is ...
0
votes
2answers
81 views

Different /bin/sh for a specific user

I am running an Ubuntu distro where /bin/sh is a symlink to /bin/dash. While this is OK for most of my users, one of them must have bin/sh "symlinked" to /bin/bash. Is that possible? I am not sure ...
0
votes
0answers
29 views

Why am I not receiving any system e-mails?

In my crontab, I have the following: * * * * * sh /home/rimmer/test.sh In /home/rimmer/test.sh I have the following: #!/bin/bash echo 'test'; I have also set chmod +x /home/rimmer/test.sh, of ...
0
votes
1answer
49 views

How to stop and continue the process

I used ps -fT pid to manage a bunch of process forked from the specified pid. Now I want to modify some settings so I want to stop the processes whose pid is in ps -fT pid. After the modification ...
0
votes
3answers
62 views

How to exec two commands in one find

I would like to find specific folders echo their name ls -l their contents My problem is that I don't know how to combine an echo {} and an ls -l {} in one find command. line for echo: sudo ...
0
votes
0answers
36 views

Exporting Variables – Reading Them Returns Blank?

Hi – I'm using Mac OS X (Mavericks), which should be UNIX compliant. In my .bash_login, I'm exporting variables for Cocos2D-X. I know this is executing, as I have a 'echo Test' line that executes ...
6
votes
2answers
179 views

What is the modification date ls reports for directories in Bash shell?

When I run ls -l in Bash shell, it lists a modification time for both files and directories. As noted in this thread, the modification time for directories does not reflect all of its contents. It ...
1
vote
1answer
36 views

What does man [-acdfFhkKtwW] mean?

I am fairly new to using the OSX terminal, so before I move forward, I want to get good at finding information out for myself. So, I was reading about the manpages about manpages, and I saw that I ...
2
votes
1answer
80 views

*nix find -type flag: can it accept multiple types?

I want to use find for getting all simlinks and regular files. I can use the -type for these individually, and I can use -o to string them together, but I apparently can't do -type fl. Is there a way ...
1
vote
1answer
22 views

Building a String of dynamic length - least consuming way?

I want to write a series of the character -, the amount equaling to 50% of the terminal window column size. I already have the column size. Let's say the terminal column size is 30. My desired end ...
2
votes
4answers
150 views

Add a display to let user wait in bash

I am looking for a pretty stupid piece of code for bash that will show a kind of "please wait" rolling display, with the characters : - \ | / The first problem is that I don't know the name of this ...
0
votes
1answer
86 views

Can I tell if I'm in an scp session in my .bashrc?

Inside my .bashrc, I'm doing a bunch of magic that causes problems when I'm trying to do an scp. The solution I've been going with is to manually ssh to the target machine, disable my .bashrc, do the ...
0
votes
2answers
132 views

Understand what is happening in Linux with ps, top, and free

I'm running my java program on a 12 cores 24 thread machine. They have several processes that are running simultaneously. It seems that I performed too many processes so that the whole tasks made the ...
2
votes
2answers
578 views

How to grep a group of files within a time range?

I'm trying to write a script used on a buffer box that does full packet capture of network traffic. As it's for a fairly big network we split the captures into 100MB segments. At times of high network ...
0
votes
1answer
182 views

How to check in shell script if output of command contains a specific word?

Sometimes I have network connectivity issues and I need to re-run the previous command. Not sure how to for the if else statement though? for var in ./* do python2.7 submit.py $var //check if output ...
0
votes
1answer
100 views

Get Rid of Error Message

I have a script with many commands. Like #!/bin/sh mv new /root/ mv old /root/ mv foo /code #many other commands If the file 'new' is not found bash will give an error message:foo: No such file ...
0
votes
2answers
283 views

Check If a script is executed as root?

I have a script that requires root privileges. I have to execute it either via sudo or from an account with uid 0 (e.g. root). If the script is not executed with sufficient rights then I want that ...
1
vote
2answers
380 views

Ignore case from user input

I'm trying to write a script to catch user input. The script should ignore the case. Consider this script foo.sh: if [ $1 == "string" ]; then echo true else echo false fi If the input of ...
0
votes
6answers
141 views

Processes currently run by users

I am looking for a unix command or a bash script to get the processes currently run by users in the system. I tried the ps -Af command, however, all the processes including the root processes pop up. ...
-2
votes
2answers
59 views

Shell variables. I'm new at this and having diffulculty

If the shell variable x has the value 5, and you reassign it with x="expr $x + 10", what is the new value of x?  What would have been the value if single quotes were used instead?  What is the most ...
1
vote
2answers
82 views

Bash: verify that process has stopped

I'm working on script meant to start/stop a set of services. For stopping, it has to terminate many processes which take a while and might hang. The script needs to verify that the process has indeed ...
0
votes
1answer
144 views

UNIX script to LPAD update query in cat file

I want script which will open the text file data and write update query to those file and save in SQL file which will get executed through cron. I have prepared command but its writing the update ...