0
votes
1answer
23 views

sed command working in command line but not in script

I have a script with the follow code: find . -name "*.html" -print0 | while IFS= read -r -d '' n; do sed -i -r 's/<font ...
1
vote
2answers
14 views

How do I show the real current directory in my bash prompt, not the symlink

I use the default value of PS1 shipped with Ubuntu: \[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$ which is ok 90% of the time. However, when I cd to a symlink "directory" the ...
3
votes
1answer
91 views

How to `rm *`, an actual file named “*”? [duplicate]

I don't know how this happened, but I have a broken symlink in my home directory named *. I was just about to rm *, and then I had a facepalm moment. Should I rm \*? rm '*'? Something else? Backing up ...
2
votes
2answers
17 views

How to recover bash output of an already closed window?

I have run a specific program in a bash terminal and I closed it by mistake before reading its output. Is it possible to recover the information that was sent to the stdout by taking a look at some ...
3
votes
4answers
21 views

How to send an `xmessage` as root remotely to regular user logged in with 'x' session?

I'm using BASH on the command line, logged into another user's PC as root, via SSH. I wish to send the user currently logged in running an X-session, a popup message, but this is the result: ...
1
vote
0answers
41 views

File shows different size after copying to another directory

I used cp -rP <dir name> <new dir name> to copy the contents of a directory, including permissions etc from one dir to another. The odd thing is, either du is giving me some strange ...
59
votes
6answers
2k views

How do perform commands in another folder, without repeating the folder path?

I was wondering if there's any clever way to do copy and move operations, or if there's a command to duplicate a file, without having to do a cd, then mv after, at the same folder. For example, I ...
1
vote
1answer
35 views

How do I install 'z' file directory jumper on linux?

I'm attempting to install this and running into issues. I am supposed to add a line to the ".bashrc" file? Where in the file? the bottom? the top? somewhere in the if statement? do I make it an alias? ...
3
votes
2answers
36 views

Append line break to command output

I have a single-line command that does a curl request to check server status and then output the result to a log file. But the problem is the returned result has no line break and so the log file ...
1
vote
3answers
83 views

Rename recursively files, while keeping the extension

I have a bunch of directories that each hold one *.txt file in it (and other non *.txt files). I'd like to rename those files recursively from the command line, basically *.txt to info.txt. So all ...
3
votes
1answer
49 views

Using grep to remove lines from a file which contain a string from another file

I have a file containing words (one per line) such as Dog Fish Cat Shoes I have a secondary file in CSV format such as 1,shoes,red 2,apple,black 3,fog,blue I would like to use grep with ...
2
votes
2answers
25 views

Place contents of last command line output into clipboard

I want to be able to run a command in my Terminal, and then quickly be able to copy the contents of the output into my clipboard without leaving my keyboard. Is there any way to do this?
1
vote
3answers
68 views

How can I reset an edited history line in Bash?

In Bash, you can press the up (and down) arrow to traverse through history. You can then modify the command before executing it. Sometimes I've incorrectly modified the command, and wish to reset it ...
2
votes
1answer
42 views

Edit Current Command in Zsh Vi Mode

So I know that you can set vi mode in bash with set -o vi I also know that you can set vi mode in zsh with bindkey -v The vi mode in bash has a great feature that allows you to edit the command ...
8
votes
6answers
279 views

In Bash (Mac/Linux terminal shell), can the up and down arrow keys be made to function as they do in text editors?

In text editors, if I press the up and down arrow keys, it moves the cursor between lines of text. In Bash, if I’m typing a long command that spans multiple lines and I press the up and down arrow ...
6
votes
4answers
148 views

How to selectively navigate through Bash command history on a Linux terminal [duplicate]

Everyone knows (or should know!) that on a terminal the up and down arrow keys are used to navigate through the history of used commands. When you use the terminal on a daily basis, your command ...
-1
votes
2answers
27 views

how to remove color from mac terminal

When I am on the Mac, the terminal is bringing up colors on the path, is there a way to remove them? This is what I have:
1
vote
1answer
42 views

Is it possible to kill a loop in bash without killing the instance of bash running the loop?

Suppose I execute (in an interactive bash shell) a loop that spawns a bunch of processes in sequence, such as the following. for i in `seq 15 42`; do if [ -f F$i.flv.mp3 ]; then play F$i.flv.mp3; fi; ...
4
votes
3answers
42 views

List file range with UNIX wildcards

Say for example I have the following files in my working directory: mjk0001.fits, mjk0002.fits, ... numerically increasing all the way to mjk9999.fits. Is there a way to use UNIX wildcards to list or ...
0
votes
2answers
59 views

Writing Unix script (bash) that creates a directory in the location specified at the command line

I currently have a Unix script (written in bash) that executes several commands to modify a group of files, which I specify with an flist containing their paths. The general idea of the script is to ...
1
vote
2answers
25 views

Remove X number of characters from command STDOUT

I'm running an application that is outputing lines, piping to GREP to select only specific lines, but want to remove the first X characters which are worthless. Specifically: varnishlog | grep Hash ...
1
vote
1answer
60 views

How to log bash command with its output?

I want the actual command line be logged together with its output. I routinely execute important commands like this: PERL5LIB=${PERL5LIB}:/something/extra my-command.pl many arguments which I want ...
3
votes
2answers
71 views

How can I easily see the man page for builtin shell commands?

If I see a command in a script that I don't know and I type (for example) man pushd or man umask I see the man page for builtin commands. I know that I can do man bash and scroll to find the help for ...
3
votes
3answers
392 views

On Linux, how can I find all files that contain a string and delete them?

I want to delete all files that contain the string foo. How can I do this using bash in Linux?
2
votes
2answers
114 views

How to persist bash history?

I don't know if this is expected, but my history is not saved across sessions. This is to say, if I close the window, then when I open it again, the history is empty. How can I persist it across ...
2
votes
2answers
44 views

How do I investigate commands being run when changing directories?

I see “awk”, “find”, “sed”, and “which” momentarily appear in my Terminal window's title when changing directories.  (And not all of these always appear and there could be some I'm missing; I imagine ...
2
votes
3answers
192 views

How to use Cmd's tab autocomplete effectively?

I've used the Bash shell on Linux for years and I'm very fast with it. By frequently appealing for autocomplete by hitting the tab key, I'm able to write long commands in few keystrokes. Recently at ...
0
votes
1answer
63 views

Program to check/look up UTF-8/Unicode characters in string on command line?

I've just realized I have a file on my system; it lists normally: $ ls -la TΕSТER.txt -rw-r--r-- 1 user user 8 2013-04-11 18:07 TΕSТER.txt $ cat TΕSТER.txt testing ... yet, it crashes a piece of ...
1
vote
1answer
27 views

How to change all occurrences of one character in a group of filenames with another?

I have some OS X files, some of which have hyphens in their filenames. I want to change all occurrences of hyphens to underscores. How can I do this from the command line on OS X? So, if I have ...
0
votes
1answer
54 views

Command line in OSX breaks when I edit bash_profile

Please help me, I am learning how to add sublime to command line from this link and when I created .bash_profile file, in the first line I typed export PATH= and saved it. My command line is broken. ...
0
votes
1answer
74 views

svn - command line - Is there a script or command that will commit every changes?

By "every change" I mean TortoiseSVN's "Commit" button. It removes the deleted files, adds new ones, and commit the changes. At least these are the ones I know of, but there may be others as well. (I ...
0
votes
2answers
40 views

BASH nested redirection debug

I know this should be easy, but the following multiple redirection just doesn't work: cat testfile > ./streamCompress > ./streamDecompress Both streamCompress and streamDecompress use input ...
1
vote
0answers
53 views

Bash Read All Characters [closed]

I need to be able to read every key that can be pressed with bash. This includes the arrow keys, esc, and the function keys. The command "read" is not going to work because some characters are more ...
2
votes
3answers
51 views

osx: selectively zip large number of files: -@ option OK?

I need to make a zip file archiving ~100k files from a directory containing ~500k files. I get "argument list too long" errors when I try the obvious commands: zip archive.zip *pattern*.txt ...
2
votes
2answers
58 views

Bash Fastest Way to Rewrite Screen

I am using bash on Mac OS X as well as Lubuntu. One of the annoying things about when I make console applications is that clear will add a whole (x-number) of lines to the console. And then I ...
1
vote
2answers
35 views

unix command zip everything except file ending with _fpartxx

I was wondering, if I have a folder structure like this: /var/www/testing/file1.iso_fpart0 /var/www/testing/file1.iso_fpart1 /var/www/testing/file1.iso_fpart2 /var/www/testing/file1.iso ...
2
votes
2answers
29 views

What file is CTRL+R searching in Debian?

With CTRL + R we can search in previous commands (in the terminal of Debian). I always assumed it was searching my .bash_history, but that doesn't seem to be the case -- right now my .bash_history is ...
0
votes
2answers
73 views

Bash script - find directory, and do something in it. Or find a file, and do something with it

This is what I have so far: for f in 'svn ls repository_dir'; do svn checkout repository_dir/$f/trunk/dir1/dir2/dir3/dir4/needed_dir done This works great for the projects (100's of them) that ...
2
votes
1answer
36 views

How to get the result from bash auto-completion as a string?

What I'm looking for is not how to add autcompletion in bash for another program, but a way to get the result of what would have happened in bash to a string, basically: autocomplete "/etc/apa" ...
0
votes
2answers
58 views

Finding not empty directories without subdirectories and specific sorting

I have a problem with my "homework" on studies. I have to list all not empty directories from /var and /usr, which do not have subdirectories and their owner is not root user. Also, for each ...
0
votes
2answers
33 views

Default text for the shell read command?

Basically I want default input that the user can edit if necessary. Eg: Please enter the city: Toronto where "Toronto" is the default text and the user can actually delete it and enter another ...
0
votes
1answer
66 views

how to extend bash history in Linux Mint 13?

How do I increase the command history size in Linux Mint 13? There is no ~./bash_profile in Linux Mint 13 and changing ~/.profile to include something like HISTSIZE=4050 HISTFILESIZE=4050 Did ...
3
votes
2answers
55 views

Generate distribution of file sizes from the command prompt

I've got a filesystem which has a couple million files and I'd like to see a distribution of file sizes recursively in a particular directory. I feel like this is totally doable with some bash/awk ...
1
vote
2answers
107 views

I want to run an rsync command at midnight but make it stop at 8am. How can i schedule the start AND END of a command?

I want to run an rsync command at midnight but make it stop at 8am. How can i schedule the start AND END of a command? I've looked into cronjobs but that will only start at a certain time. Any ideas ...
2
votes
1answer
33 views

bash - i'm doing for i in *.mp4, then in the loop i want to use ${i} but without the .mp4. how can i do this?

Basically i am doing this: for i in *.mp4; do ffmpeg -i "${i}" -vf "movie=logo.png [watermark]; [in][watermark] overlay=10:10 [out]" -strict -2 -qscale 0 "${i}-watermarked.mp4"; done; but this ...
0
votes
3answers
46 views

Bash PS1 string that evaluates certain code every time it is looked up

This question is very similar to this one: Colored PS1 string But I still don't understand completely. So say I have this function function getjobs { echo $(jobs | wc -l) } And my PS1 is ...
0
votes
1answer
82 views

How to escape the arguments correctly when calling cygwin bash -c?

I am trying to call the scanimage command (from the SANE tool) from inside cygwin though I think that my problem is one of general escaping so maybe what I am calling doesn't matter. Anyway... The ...
1
vote
2answers
101 views

How list file by range of date?

I would like to list files with 3 days years old. I found this one at stackoverflow: find . -type f -printf "%-.22T+ %M %n %-8u %-8g %8s %Tx %.8TX %p\n" | sort | cut -f 2- -d ' ' | grep 2012 But I ...
2
votes
1answer
80 views

Redo typing in OSX bash

In bash on OSX I can do ctrl-_ to undo what I most recently typed. Is there a corresponding redo command?
0
votes
1answer
56 views

gzip many files one by one

I have 100 files, n1.txt, n2.txt,… and I want to gzip each of them, but not in one file – finally I'd like to have 100 n*.txt.gz files. How can I do that in Linux with Bash?

1 2 3 4 5 6