Bash is a free shell for Unix-like operating systems from the GNU Project.

learn more… | top users | synonyms

3
votes
4answers
993 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 ...
0
votes
4answers
166 views

how to access homedir by root user

I want to access root user's home directory /root/. However following commands dont lead me to the root directory. sudo -s cd ~ It leads to the home dir of regular user. How to access /root ...
0
votes
4answers
928 views

using awk to make exact matches

i'm just wondering how can we use awk to do exact matches. for eg $ cal 09 09 2009 September 2009 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ...
1
vote
3answers
1k views

How do I set the Android bash path in ZSH?

Looking through the Cordova Android docs, I see this line You need to add the path to your Android SDK platform-tools and tools directory. In my example I will use ...
1
vote
3answers
2k views

Loop through a directory unix shell programming

Use a for loop to go through the filenames in the directory. In this version, only loop through the filenames that do not have a ".old" extension Inside the loop, rename the file to the new name.
1
vote
3answers
240 views

Read everything that has been echo'd and 'errored' to terminal window?

I've inherited a complex shell script running on OSX that gets run on a crontab. Within the script I would like to periodically read everything in the terminal window and write it to another file... ...
0
votes
3answers
27 views

Parameter substitution in sh -c

I have a large number of log files, the idea is to group them by date/month and then pack into archives. Here's my script: find /c/this/path/ -type f -name "$file_pattern" | xargs -I fn basename fn ...
0
votes
3answers
61 views

Is there a way to determine which user ran a command in bash history?

We work on CentOS servers available to over a hundred employees via SSH, each with their own login. Running a normal history bash command shows all of the commands ran by all of the employees, however ...
0
votes
3answers
23 views

Auto-replace special characters in input / bash?

Let's say, I have the following in my .bashrc test1() { echo $@; } and I want the following to run in my terminal test1 1 and (2 and 3) which should output 1 and (2 and 3) But this just ...
0
votes
3answers
576 views

How to copy multiple files and move them to multiple folders using terminal for Mac

I have a folder on my Mac's desktop called Bthepics that has 9 images that I want to copy and move to about 500 folders at once. These 500 folders are located in a folder on my Mac's desktop called ...
0
votes
3answers
88 views

Check which string occurs first in a growing file

I'm running a remote executable which produces a logfile. I want to write a script to check whether the executable is run successfully or encounters an error. The way I can do this is by looking at ...
0
votes
3answers
122 views

Grep for block surrounding an error message

I want to grep for the block of logs around a particular error message. Say I know my log looks like this: [----] I, [2014-04-10T19:12:36.294512 #1910:e93004] INFO -- : Started GET "/ems_infra/new" ...
0
votes
3answers
161 views

Running BASH Script on a Remote Windows Machine from Linux Machine

I am planning to run a BASH script on a remote Windows system from my local Linux machine. For this purpose, I will have to login to Windows machine from the local one and then execute the BASH ...
0
votes
3answers
132 views

Replace string in string but not when its somewhere between double square bracket

I have a long string from mysql field containing the data of a mediawiki page. I have to replace a string in that mediawiki page but not when the string is in mediawiki link. The mediawiki link is ...
0
votes
3answers
728 views

Bash - Move those files that contain the string to directory

Task: Create script, that will take 2 arguments: 3.sh <directory> <destination> Search the files in <directory> for substring “moveme” in the file content Move those files that ...
0
votes
3answers
56 views

Matching a sequence of symbols in bash

I would like to list all Fortran 90 files in bash without files ending in _tst.f90. My best try so far is ls -l ../src/*[!_tst].f90 According to Bash reference on pattern matching [!_tst] takes ...
0
votes
3answers
146 views

Listing files, including archive contents

Is there some method to find, from the shell, all files matching a file pattern including those inside archives (specifically: zip archives)? The simulation package "VASP" produces files called ...
0
votes
3answers
616 views

How do I remotely execute scripts on multiple servers, mix output

Hi I'm looking for a piece of software or some sort of technique that would enable me to do following in one terminal window: Take as input a list of ssh-enabled machines with login, password and ...
0
votes
3answers
285 views

How to mount a Windows shared drive on OS X given a Windows user like this: myserver@mydomain.com

I have a script in OS X which is something like this: tell application "Finder" try mount volume "SMB://myuser:mypwd@myhost/sharedfolder" end try end tell It works fine, but now ...
0
votes
3answers
191 views

Mac Terminal -bash warnings on start

Upon opening a new Terminal window on my Mac, I always get the following message - Last login: Wed xx xxxxx on xxxxx -bash: export: `-s': not a valid identifier -bash: export: ...