0
votes
0answers
8 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 ...
3
votes
0answers
454 views

Unix: “ls” command shows files with ? after the extension [migrated]

I have written a shell script (test.sh) using Java. This shell script actually does a copy job from one file to the other. After the execution of the shell script I have opened the directory from ...
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 ...
0
votes
2answers
16 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
32 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
52 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
31 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
46 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
213 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
28 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
37 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
26 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
63 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
37 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
69 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
54 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
105 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
27 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
64 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
28 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
45 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
56 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
30 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
136 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
35 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
53 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
19 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
127 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
40 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
120 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
425 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
171 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
91 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
181 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
266 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
124 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
55 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
76 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
107 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 ...
2
votes
2answers
60 views

List folders in Linux which can only be seen if accessed

Maybe it is a amateur question but here it goes: At the university we have a folder /vol. This folder is absolutely empty until you "cd" into a directory which exist there. E.g. "cd ...
1
vote
2answers
88 views

How to use 2x$$ together linux

the questing is how to use two variables togheter.. ex. $1,$2,$3 are set numb=2 I need to use command: head $$numb that must be the same as: head $2 I tried everything, I need to know what ...
1
vote
0answers
46 views

shell script for finding the unix noun phrase

one entry in the on database is: LPE-1*story#1/1 of pearl#1/2*historia de la perla*storia della perla* histoire de la perle* história da pérola*istoria perlei*TOPIC The fields are separated by ...
3
votes
1answer
3k views

BASH - merge directories when using mv

I just started using BASH, so I can move all contents of a directory to another. But the issue is, I was expecting it to merge the directories. I am using cron job to run this script. #!/bin/bash ...
1
vote
1answer
66 views

Problems after installing Microsoft Services for UNIX

I had Cygwin installed and everything worked liked a charm. At some point I installed Microsoft Services for UNIX on my computer and the problems started. When I open up a commnad shell an wanna try ...
0
votes
4answers
183 views

bash - directories ending in . and whitespace cannot be removed

On my external hard drive are two directories, Fun. and Complex_, where that _ is a whitespace. I cannot empty from my trash or remove them with rm -rf and I want to. Neither show up in Finder on ...
5
votes
2answers
302 views

How do I make my script ask for a password, like sudo?

I am writing a script which would be potentially dangerous if run in the wrong way. As a safety feature, I want the script to require the user to re-enter their password first, much as sudo does. So ...
1
vote
1answer
68 views

Changing chmod flags back

I'm fairly new to the whole UNIX / command shell sort of stuff, so I apologize for any ignorance for something I am not aware of. And by new, I mean extremely new. I was confused by how to change a ...
0
votes
1answer
79 views

head hangs or doesn't terminate on Linux

I'm using, (uname -a says) Linux ip-x-x-x-x 2.6.21.7-2.fc8xen-ec2-v1.0 #1 SMP Tue Sep 1 10:25:30 EDT 2009 x86_64 GNU/Linux. I've got a script, foo.sh with 100 lines of code and when I run head ...
3
votes
1answer
514 views

How to get list of all child process spawned by a script

Context: Users provide me their custom scripts to run. These scripts can be of any sort like scripts to start multiple GUI programs, backend services. I have no control over how the scripts are ...
0
votes
2answers
155 views

Automatic file versioning on Linux

I want to do the following: when a file is changed then the old file should be backed up to another location with different name on Linux. E.g. whenever example.text is changed, at each change, new ...