Search Results

Search found 5228 results on 210 pages for 'bash alias'.

Page 29/210 | < Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >

  • "This Friday" in bash script

    - by Ben
    Hi, Is there a way to calculate a time stamp for the next coming up of a week day? So for instance, with friday, i'd like to be able to run some code that calculates that from today Wednesday 19/05/10, the next friday will be 21/05/10 and get a time stamp from it. I know the date command can parse a given string date according to a format, but I can't figure out how to calculate "next friday from today" Any idea? Cheers Ben

    Read the article

  • Bash: using commands as parameters (specificly cd, dirname and find)

    - by sixtyfootersdude
    This command and output: % find . -name file.xml 2> /dev/null ./a/d/file.xml % So this command and output: % dirname `find . -name file.xml 2> /dev/null` ./a/d % So you would expect that this command: % cd `dirname `find . -name file.xml 2> /dev/null`` Would change the current directory to ./a/d. Strangely this does not work. When I type cd ./a/d. The directory change works. However I cannot find out why the above does not work...

    Read the article

  • Messy bash variable

    - by Kyle
    I'm writing a script to ssh in to a list of machines and compare a variable to another value.. I've run into a problem (I have a couple workarounds, but at this point I'm just wondering why this method isn't working). VAR=ssh $i "awk -F: '/^bar/ {print \$2}' /local/foo.txt" ($i would be a hostname. The hosts are trusted, no password prompt is given) Example of foo.txt: foo:123456:abcdef bar:789012:ghijkl baz:345678:mnopqr I'm assuming it's a problem with quotes, or \'s needed somewhere. I've tried several methods (different quoting, using $() instead of ``, etc) but can't seem to get it right. My script is working correctly using the following: VAR=ssh $i "grep bar /local/foo.txt" | awk -F: '{print \$2}' Like I said, just a curiousity, any response is appreciated.

    Read the article

  • bash: listing files in date order, with spaces in filenames

    - by Jason Judge
    I am starting with a file containing a list of hundreds of files (full paths) in a random order. I would like to list the details of the ten latest files in that list. This is my naive attempt: ls -las -t `cat list-of-files.txt` | head -10 That works, so long as none of the files have spaces in, but fails if they do as those files are split up at the spaces and treated as separate files. I have tried quoting the files in the original list-of-files file, but the here-document still splits the files up at the spaces in the filenames. The only way I can think of doing this, is to ls each file individually (using xargs perhaps) and create an intermediate file with the file listings and the date in a sortable order as the first field in each line, then sort that intermediate file. However, that feels a bit cumbersome and inefficient (hundreds of ls commands rather than one or two). But that may be the only way to do it? Is there any way to pass "ls" a list of files to process, where those files could contain spaces - it seems like it should be simple, but I'm stumped.

    Read the article

  • Bash script to replace spaces in file names

    - by armandino
    Can anyone recommend a safe solution to recursively replace spaces with underscores in file and directory names starting from a given root directory? For example, $ tree . |-- a dir | `-- file with spaces.txt `-- b dir |-- another file with spaces.txt `-- yet another file with spaces.pdf becomes $ tree . |-- a_dir | `-- file_with_spaces.txt `-- b_dir |-- another_file_with_spaces.txt `-- yet_another_file_with_spaces.pdf

    Read the article

  • New Application Process from Bash Shell

    - by Thomas Uster
    I'm relearning UNIX commands to use git on windows using MINGW32. When I launch a program, for example "$ notepad hello.txt" I can't use the shell again until I close the notepad file or CTRL-C in the shell. How do I essentially fork a new process so I can use both programs?

    Read the article

  • bash script variable inside variable

    - by user316100
    x=1 c1=string1 c2=string2 c3=string3 echo $c1 string1 I'd like to have the output be string1 by using something like: echo $(c($x)) So later in the script I can increment the value of x and have it output string1, then string2 and string3. Can anyone point me in the right direction?

    Read the article

  • bash/ksh/scripting eval subshell quotes

    - by jhon
    Hi tehere, I'm using ksh and have some little troubles, could you help me? why does not this code run? [root]$ CMD="ls -ltr" [root]$ eval "W=$( $CMD )" [root]$ ksh: ls -ltr: not found. [root]$ echo $W and this works fine: [root]$ CMD="ls -ltr" [root]$ eval 'W=$('$CMD')' [root]$ echo $W Thanks :-)

    Read the article

  • Test whether a glob has any matches in bash

    - by Ken Bloom
    If I want to check for the existance of a single file, I can test for it using test -e filename or [ -e filename ]. Supposing I have a glob and I want to know whether any files exist whose names match the glob. The glob can match 0 files (in which case I need to do nothing), or it can match 1 or more files (in which case I need to do something). How can I test whether a glob has any matches.? (test -f glob* fails if the glob matches more than one file.)

    Read the article

  • Writing from an array to a file bash and new lines

    - by S1syphus
    I'm trying to write a script the generates a template file for Pashua (a perl script for creating GUI on osx) I want to crate an instance for each item in the array, so the ideal output would be: AB1.type = openbrowser AB1.label = Choose a master playlist file AB1.width=310 AB1.tooltip = Blabla filesystem browser AB2.type = openbrowser AB2.label = Choose a master playlist file AB2.width=310 AB2.tooltip = Blabla filesystem browser ...and so on for the rest of the array: What I am using to write to the text file at the moment is: count=1 saveIFS="$IFS" IFS=$'\n' array=($(<TEST.txt)) IFS="$saveIFS" for i in "${array[@]}"; do declare AD$count="$i"; ((count++)); done for i in "${array[@]}"; do echo "AD$count".type = openbrowser "AD$count".label = Choose a master playlist file \n "AD$count".width=310 \n "AD$count".tooltip = Blabla filesystem browser \n" >> long.txt; done However \n doesn't produce a newline in the text file, and I am pretty sure there is a alot nicer way todo this, ideas?

    Read the article

  • Execute a BASH command in Python-- in the same process

    - by Baldur
    I need to execute the command . /home/db2v95/sqllib/db2profile before I can import ibm_db_dbi in Python 2.6. Executing it before I enter Python works: baldurb@gigur:~$ . /home/db2v95/sqllib/db2profile baldurb@gigur:~$ python Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ibm_db_dbi >>> but executing it in Python using os.system(". /home/db2v95/sqllib/db2profile") or subprocess.Popen([". /home/db2v95/sqllib/db2profile"]) results in an error. What am I doing wrong? Edit: this is the error I receive: > Traceback (most recent call last): > File "<file>.py", line 8, in > <module> > subprocess.Popen([". /home/db2v95/sqllib/db2profile"]) > File > "/usr/lib/python2.6/subprocess.py", > line 621, in __init__ > errread, errwrite) File "/usr/lib/python2.6/subprocess.py", > line 1126, in _execute_child > raise child_exception OSError: [Errno 2] No such file or directory

    Read the article

  • awk/sed/bash to merge data

    - by Kyle
    Trying to merge some data that I have. The input would look like so: foo bar foo baz boo abc def abc ghi And I would like the output to look like: foo bar baz boo abc def ghi I have some ideas using some arrays in a shell script, but I was looking for a more elegant or quicker solution.

    Read the article

  • Placement of command line options in bash

    - by Nathan Rambeck
    I just starting using a Mac and have been frustrated that command line options are required immediately following the command so that this works: ls -la /usr but this doesn't: ls /usr -la ls: -la: No such file or directory Is there any way to change this? Or can someone tell me why the placement of options is agnostic on most Linux platforms, but not on Mac?

    Read the article

  • bash grep finding java declarations

    - by Amarsh
    i have a huge .java file and i want to find all declared objects given the className. i think the declaration will always have the following signature: className objName; or className objName = or className objName= can someone suggest me a grep pattern which will find these signatures. I have the following (incomplete) : cat $rootFile | grep "$className "

    Read the article

  • Bash: using commands as parameters (specifically cd, dirname and find)

    - by sixtyfootersdude
    This command and output: % find . -name file.xml 2> /dev/null ./a/d/file.xml % So this command and output: % dirname `find . -name file.xml 2> /dev/null` ./a/d % So you would expect that this command: % cd `dirname `find . -name file.xml 2> /dev/null`` Would change the current directory to ./a/d. Strangely this does not work. When I type cd ./a/d. The directory change works. However I cannot find out why the above does not work...

    Read the article

  • Passing parameters to a shell script running as a cronjob

    - by Takashi
    I am new to bash scripting (not programming in general). I am writing a bash script that will run a Python script I have written. I want to be able to do the following: Pass parameters to the bash script via the cronjob (so I can have two cron jobs) one to be run with parameter 'foobar', and the other 'foo' switch based on the parameter passed to the bash script (by switching, I mean an if/else based on the paramter passed to the bash script).

    Read the article

  • Bash PS1 settings - how to get the current folder back as the terminal title

    - by Max Williams
    Hi all. I recently added these lines to my ~/.bashrc file to show the current branch if i'm in a git working folder, and it works nicely for that. However, what i've lost is that the current folder name used to be shown in the tab for the terminal i have open, and now it isn't: it always just says 'Terminal'. Can i get that back and still keep the git stuff? Here's the lines in question - it's the second one that's the issue, as commenting out just the second line fixes the problem. source /etc/bash_completion.d/git PS1='\h:\w$(__git_ps1 "\[\e[32m\][%s]\[\e[0m\]")$ ' I've been looking at explanations of the options for PS1 but can't see anything about the terminal window's title in there. Can anyone advise? thanks, max

    Read the article

  • Using bash to copy file to spec folders

    - by Franko
    I have a folder with a fair amount of subfolders. In some of the subfolders do I have a folder.jpg picture. What I try to do find that folder(s) and copy it to all other subfolders that got the same artist and album information then continue on to the next album etc. The structure of all the folders are "artist - year - album - [encoding information]". I have made a really simple one liner that find the folders that got the file but there am I stuck. ls -F | grep / | while read folders;do find "$folders" -name folder.jpg; done Anyone have any good tip or ideas how to solve this or pointers how to proceed? Edit: First of all, i´m real new to this (like you cant tell) so please have patience. Ok, let me break it down even more. I have a folder structure that looks like this: artist1 - year - album - [flac] artist1 - year - album - [mp3] artist1 - year - album - [AAC] artist2 - year - album - [flac] etc I like to loop over the set of folders that have the same artist and album information and look for a folder.jpg file. When I find that file do I like to copy it to all of the other folders in the same set. Ex if I find one folder.jpg in artist1 - year - album - [flac] folder do I like to have that folder.jpg copied to artist1 - year - album - [mp3] & artist1 - year - album - [AAC] but not to artist2 - year - album - [flac]. The continue the loop until all the sets been processed. I really hope that makes it a bit more easy to understand what I try to do :)

    Read the article

  • Substring extraction using bash shell scripting and awk

    - by rohanbk
    So, I have a file called 'dummy' which contains the string: "There is 100% packet loss at node 1". I also have a small script that I want to use to grab the percentage from this file. The script is below. result=`grep 'packet loss' dummy` | awk '{ first=match($0,"[0-9]+%") last=match($0," packet loss") s=substr($0,first,last-first) print s}' echo $result I want the value of $result to basically be 100% in this case. But for some reason, it just prints out a blank string. Can anyone help me?

    Read the article

  • BASH tr command

    - by user1457809
    Id like to convert it to uppercase for the simple purpose of formatting so it will adhere to a future case statement. As I thought case statements are case sensitive. I see all over the place the tr command used in concert with echo commands to give you immediate results such as: echo "Enter in Location (i.e. SDD-134)" read answer (user enters "cfg" echo $answer | tr '[:lower:]' '[:upper:]' which produced cfg # first echo not upper? echo $answer #echo it again and it is now upper... CFG

    Read the article

  • Check if a program exists in bash

    - by ~rojanu
    I am trying to check if md5sum or digest exists on solaris and script is used on different machines. Here is the function in sh script which is called from a ksh script getMD5cmd () { PATH="${PATH}:/bin:/usr/bin:/usr/sfw/bin:/usr/local/bin:/usr/sbin/bin" if type -p md5sum;then MD5CMD=`type -p md5sum` elif type -p digest;then MD5CMD="`type -p digest` -a md5" fi echo "HERE ${MD5CMD}" } When I run scripts I get -p not found md5sum not found -p not found digest is /bin/digest HERE However, when I type it in a terminal, works as exptected Any Ideas? Thanks

    Read the article

  • Bash: infinite sleep

    - by watain
    I use startx to start X which will evaluate my .xinitrc. In my .xinitrc I start my window manager using /usr/bin/mywm. Now, if I kill my WM (in order to f.e. test some other WM), X will terminate too because the .xinitrc script reached EOF. So I added this at the end of my .xinitrc: while true; do sleep 10000; done This way X won't terminate if I kill my WM. Now my question: how can I do an infinite sleep instead of looping sleep? Is there a command which will kinda like freeze the script? Best regards

    Read the article

  • Bash: how to supress newlines?

    - by gilgongo
    I'm trying to extract fields from a pipe-delimited file and provide them as arguments to an external program in a loop. The file contains lines like this: value1|value2 value3|value4 So I came up with: while read line; do echo -n "${line}" | awk -F '|' '{print $1}'; echo -n " something "; echo -n "${line}" | awk -F '|' '{print $2}'; echo " somethingelse"; done < <(cat $FILE) I want to see the following output: value1 something value2 somethingelse value3 something value4 somethingelse But instead I'm getting: value1 something value2 somethingelse value3 something value4 somethingelse Perhaps I shouldn't be using echo?

    Read the article

  • awk/sed/bash to merge/concatenate data

    - by Kyle
    Trying to merge some data that I have. The input would look like so: foo bar foo baz boo abc def abc ghi And I would like the output to look like: foo bar baz boo abc def ghi I have some ideas using some arrays in a shell script, but I was looking for a more elegant or quicker solution.

    Read the article

< Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >