Tagged Questions
19
votes
5answers
13k views
Split pages in pdf
I have a scanned pdf file which has scanned two pages on one virtual page (page in pdf file).
The resolution is with good quality. The problem is I have to zoom when reading and drag from left to the ...
17
votes
1answer
494 views
Is there a standard command that always exits with a failure?
I want to test my script with a command that fails. I could use an existing command with bad arguments. I could also write a simple script that immediately exits with a failure. Both of these are easy ...
11
votes
2answers
5k views
find n most frequent words in a file
I want to find, say, 10 most common word in a text file. Firstly, solution should be optimized for keystrokes (in other words - my time). Secondly, for the performance. Here is what I have so far to ...
7
votes
2answers
498 views
Shell Script for going through a dir recursively and chmodding based on conditions of file type
Can anyone point me to either code or a tutorial for writing a shell script that can recursively go through an entire directory structure (starting at the current working directory, or given an ...
7
votes
4answers
740 views
What is the easiest way to execute text from tail at the command line?
Sometimes I'm working on a new (ubuntu) box and I type git and am alerted:
The program 'git' is currently not installed. You can install it by typing:
apt-get install git-core
If that happens I ...
7
votes
2answers
1k views
XFCE or pure X11 commands, toggle compositing immediately without restarting X
How can i disable compositing via the command line? I need to disable temporarily for some games, like Nexuiz, for use in a wrapper script to toggle compositing status.
6
votes
5answers
20k views
How can I monitor all outgoing requests/connections from my machine?
My machine is a server so I want to ignore connections being made to my server (e.g. when someone visits my website). I want to see only connections/requests being made by my server to other places.
...
6
votes
3answers
1k views
How to tweet using terminal?
I would like to tweet a message using terminal.
I tried something like:
curl -u 'TwitterUsername':'TwitterPassword' -d status=”Your Message Here” https://twitter.com/statuses/update.xml
but seems ...
5
votes
3answers
6k views
Storing output of command in shell variable
I have an operation using cut that I would like to assign result to a variable
var4=echo ztemp.xml |cut -f1 -d '.'
I get the error:
ztemp.xml is not a command
The value of var4 never gets ...
5
votes
2answers
1k views
How to list files and directories with directories first
I have two questions. First, which command lists files and directories, but lists directories first?
Second question: I want to copy a list of files into a single directory, but make the target ...
4
votes
4answers
847 views
Why cat, grep and other commands can't understand files starting with minus sign? [duplicate]
If I have a file which name starting with single or several minus sign, for example --1 it can't be used as a parameter of many commands. Even if I run
cat --1
instead of file content I get ...
4
votes
4answers
2k views
How can I pass a command line argument into a shell script?
I know that shell scripts just run commands as if they were executed in at the command prompt. I'd like to be able to run shell scripts as if they were functions... That is, taking an input value or ...
4
votes
3answers
1k views
Use & (ampersand) in single line bash loop
I have been using this command successfully, which changes a variable in a config file then executes a Python script within a loop:
for((i=114;i<=255;i+=1)); do echo $i > numbers.txt;python ...
4
votes
3answers
225 views
How to pass each line of a text file as an argument to a command?
I'm looking to write a script that takes a .txt filename as an argument, reads the file line by line, and passes each line to a command. For example, it runs command --option "LINE 1", then command ...
4
votes
2answers
213 views
Dump process's stdin and stdout
I have two processes, let's say Parent and Child. Parent launches the Child and communicates with it through child's stdin and stdout.
Parent <-> Child
These processes use text protocol and I ...
4
votes
1answer
1k views
How to create a confirmation question in Linux?
I have a certain command (git push server-name) that has major consequences. How to require confirmation for this command only? It should ignore white space.
The confirmation could be Enter 'yes i am ...
4
votes
3answers
780 views
What's the best way to determine the working directory for UNIX process using 'ps'?
I am running a Ruby command line script (rufus.sh)which ultimately calls Thread.new, which spawns a UNIX process as shown below. I run this script for more than 1 directory as the output of the ps ...
3
votes
2answers
2k views
Passing a bash command-line argument containing a dot
How can a command-line argument containing a dot (.) be passed? Are there any escape sequences for capturing characters like dot?
The following invocation of a bash-script from the shell does not ...
3
votes
3answers
377 views
How to move the first x files
I have this huge folder with thousands of unordered files. Is it feasible to move the first 5000s to a subfolder via the mv command? For now I move files with
mv *some_pattern* ./subfolder1/
...
3
votes
2answers
648 views
Move with possible rename
Is it possible to construct a command that will move the file to another directory and if the same file is already there, generate some random string that is not in the name of some file in the ...
3
votes
2answers
392 views
How can I determine if HTML5 player is running in browser?
I would like to find a command-line or a script that will show me if HTML5 player is running or not in a browser (firefox or chromium).
For example, to determine if Flash player is running in a ...
3
votes
2answers
199 views
Make copies of a single directory to multiple directories with different names
I'm trying to replicate a single directory (with sub-directories) to a bunch of new directories based on a list. For example I can:
mkdir Fred Barney Thelma Louise Foo Bar
How would I copy a premade ...
3
votes
1answer
373 views
Extract directory from wget's stdout
I am trying to wget a tarball from github.com and, without creating a temporary file, extract a subdirectory from it:
wget -qO- https://github.com/django-nonrel/django-nonrel/tarball/develop | tar ...
3
votes
1answer
352 views
Multiple renaming files [duplicate]
Possible Duplicate:
How to clean up file extensions?
I'd like to rename files with extension .flac.mp3 to extension .mp3.
I used the following command
$ for i in *; do mv $i `echo $i | sed ...
3
votes
1answer
236 views
Pausing rsync via bash script?
Is there a way to pause rsync via command line, if it transfers data for over X minutes? I'm working on using it as a backup and would like it to pause every once in a while to prevent the hard disks ...
3
votes
1answer
299 views
Conditionally killing a process based on its output
I have a REPL (read-eval-print-loop) for the Clojure programming language listening on a network socket. I can send it code over the network and the code will be evaluated and the answer sent back to ...
2
votes
1answer
385 views
Help me parse this `find` command
Following command tells me the length of mp4 video files:
find -type f -name "*.mp4" -print0 | \
xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | \
perl -nle ...
2
votes
1answer
4k views
How to get exact file size and file name?
Right now I am using ls -lt /my/directory (see below) then php parses the output. But inconsistently because the delimiter is space and there might be two or more spaces in between two fields.
The ...
2
votes
2answers
789 views
creating simple command for sudo apt-get install?
I need to run these commands very often:
sudo apt-get install <package>
sudo apt-get remove <package>
Can I make it simple like:
install <package>
remove <package>
I ...
2
votes
2answers
941 views
How to make duplicates with different names from a single file? [closed]
I want to duplicate the contents of a file. Suppose there is a file named "Hydrogen.element". I want to duplicate the contents of this file with a different name ie.make another file named ...
2
votes
2answers
92 views
How can I execute a shell script that exists in a longish path with a single command without first cd'ing to the directory?
In Linux I always cd to a longish path and then run the script:
cd /scratch/someDir/someOthernestedDir/
./shellscriptName.sh
How can I avoid achieve typing this longish path and then executing ...
2
votes
2answers
930 views
Concatenate multiple files under subdirectories
My directory structure is given below
x:\Project_2012-158A\Sample_4041
SampleSheet.csv
4041_CGTACG_L002_R1_001.fastq
4041_CGTACG_L002_R2_001.fastq
4041_CGTACG_L006_R2_001.fastq
...
2
votes
1answer
87 views
Any better method than this for sorting files by their creation date?
I needed to display a list of directories sorted by their creation date and I came up with this code snippet that I thought was kind of clever. Is there a more obvious way to do this that I'm missing?
...
2
votes
2answers
1k views
How to build a long command string?
I've a sequence of commands to be used along with lot of pipings, something like this:
awk '{ if ($8 ~ "isad") {print $2, $5, "SE"} else {print $2, $5, "ANT"} }' ...
2
votes
1answer
1k views
Start 4 programs on startup in Linux Mint via terminal
I'm working on a project and I hope you can help me solve a problem.
I have four programs that are written in C. They have been compiled using gcc and they work as they should. Because the four ...
2
votes
1answer
122 views
Is there a text-only equivalent (no curses) of `zenity --question`?
For my mercurial commit hook, I want to run my test cases and be asked whether I really want to commit if any of the tests fail. I'm thinking something like <run-the-tests> || ...
2
votes
1answer
126 views
Output redirection and spaces
I'm paranoid about this, but hopefully it's a simple question:
Is there any difference between
cat file1 | egrep -oP "[Mm]y string" > /home/user/file.txt
and
cat file1|egrep -oP "[Mm]y ...
2
votes
1answer
146 views
How to have find only search for files in changed directories?
Currently I'm repeatedly doing a 'find' that's too slow. I'm searching for non-hidden executable files within "$root", excluding "$root/bin":
find "$root" -type f -perm -o+x -not -path "$root/bin/*" ...
2
votes
1answer
55 views
Memory buffer in a bash script
I have recently finished a script that will ask for a hostname and automatically take the argument of the function and ssh into one of my work servers.
Here is a copy of my script:
#!/bin/bash
echo ...
2
votes
2answers
356 views
Executing zsh rehash after build
I have a build script that can change what binaries are in my $PATH (it doesn't edit $PATH itself, but it adds/deletes files to folders that are already in $PATH). zsh's autocompletion doesn't update ...
2
votes
1answer
187 views
Merging folders with practically the same name but different casing
When digging around in the advanced settings in Dropbox I lost a folder. I only discovered this about a month later. I managed to get this folder back from Dropbox however the file structure of the ...
1
vote
3answers
309 views
Which cmd is the best for determining the OS' word size (32/64)-bit? [duplicate]
I need to find my OS (not hardware) is 32-bit / 64-bit. Which command is best?
uname -p
uname -i
uname -m
arch
All the above commands returns the same answer:
On 32 bit systems: i686/i386
On ...
1
vote
1answer
105 views
Is there a graphical shell or scripting environment for Linux?
I would like to draw my scripts and connect commands like blocks of functions (something similar to Yahoo Pipes). Does such an environment exist or do I have to develop it myself?
1
vote
2answers
80 views
Pass a command to ROOT from a shell script and having it stay open
I am writing a bash script to perform some analysis using the program ROOT. I want to run some initial command to load the result of the analysis, then continue using ROOT interactively.
The analysis ...
1
vote
1answer
55 views
Formatting an external HDD with Bash script
At my workplace we have an external HDD connected to a NAS device (Synology).
There is a backup tasks which runs weekly and fills the external HDD after a while. Unfortunately the Linux-based OS of ...
1
vote
1answer
65 views
Does cron impose some limitations to types of commands and privilege of execution? [duplicate]
I've experienced an issue where some of my scripts run perfectly fine when I call them manually, but these same scripts when called as cron jobs via cron don't seem to work at all.
So my question: ...
1
vote
1answer
86 views
What is the use of ; in a single line command?
What does ; mean in single line scripts like this:
while true; do sudo -n true; sleep 60; kill -0 '$$' || exit; done 2>/dev/null &
Does it mean new line, or "next command"?
1
vote
1answer
786 views
How to format a curl command for a special task?
There is a search page in a form http://site.com/search.php and it sends a search query via POST request. I want to fetch this request via curl command line tool to inspect a POST request.
The HTML ...
1
vote
1answer
65 views
Change a value in a config file, or add the setting if it doesn't exist?
When modifying config files from the command line, I often want to find the setting in the config file and modify that line if that setting exists. If that setting doesn't exist, I want to add it to ...
1
vote
0answers
55 views
Changing KDE's mouse theme and buttons settings from a shell script
I'm trying left handed mousing, and I want to be able to easily switch between right handed mode and left handed mode. There is a utility for Windows called SwapMouseButtons that allows to bind a key ...