1
vote
1answer
29 views

View timestamp for CUPS print jobs

I'm looking for a way to view the timestamp of a job in CUPS. I've searched the man pages and can't seem to find it. The long term goal is to have a script that parses the time from the jobID and ...
2
votes
1answer
180 views

How to remove file log with file name

Assume, I have log files with this name format. NameLog.log.2014-09-27 NameLog.log.2014-09-28 NameLog.log.2014-09-29 NameLog.log.2014-09-30 NameLog.log.2014-10-01 NameLog.log.2014-10-02 ...
16
votes
7answers
705 views

How to efficiently generate large, uniformly distributed, random integers in bash?

I have been wondering what would be the best way to get good randomness in bash, i.e., what would be a procedure to get a random positive integer between MIN and MAX such that The range can be ...
3
votes
2answers
105 views

get result text from CLI command

I'm writing a bash script and I need to capture the text resulting from the output of the rsync command, for instance, the following command: rsync -av "$FOLDER1" "$FOLDER2" prints: ... sent ...
1
vote
1answer
98 views

Command-line parameters in bash script not recognised

I use Debian (Raspbian) Wheezy. If this command line works fine: smsd -c sms/out -i 60 -0 -f sms/smsd.log and this alias also works fine: bsmsd='smsd -c sms/out -i 60 -0 -f sms/smsd.log' then ...
2
votes
2answers
237 views

How parse a log file for a string, and when found search backwards for another string

I use the following command to parse a log file for a particular string. Then I search backwards in the log to find the data I really want. The problem as in the example below, I am only going back ...
4
votes
3answers
755 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 ...
0
votes
1answer
56 views

How to start a cron task?

It sounds really simple, but many times I was stuck at the beginning of learning a new command. The tutorial writer think it's natural to start, but it's not. This is the tutorial I've been reading: ...
1
vote
2answers
139 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 ...
2
votes
1answer
71 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 ...
1
vote
1answer
134 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
234 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
121 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 ...
0
votes
1answer
107 views

Recursively delete hidden directory & its files?

I want to delete all hidden directoris from a directory and its sub-directory. I also use rm -rf .directory_name this command is iterative command I want to a recursive command. Please anybody help ...
1
vote
1answer
76 views

What is the Command to check the history of the command executed which should based on the user who accessed it [closed]

I am looking for the command or script to meet the following requirement. I wanted a history of all the users who connected to my machine and what commands they execute in there session and at which ...
4
votes
2answers
254 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 ...
1
vote
1answer
127 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?
0
votes
0answers
20 views

Multiply 2 array index variables shell programming [duplicate]

How do i multiply 2 array index variables given the following foo=(1 2) bar=(0.1 0.2) foobar=$((foo[1]*price[1])) # this is wrong echo "$foobar" Current output : 0 Correct/Expected output : 0.4
1
vote
1answer
85 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: ...
-2
votes
1answer
91 views

how do I make a $VAR empty so it don't effect the command line argument and still be within that argument?

This is the basic setting for hsetroot for it to work: hsetroot -center /path/to/image/ - setting the wallpaper with just that the picture. To use these options, just one has to be place within the ...
3
votes
3answers
577 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/ ...
0
votes
1answer
580 views

Script for running sequential job

I started recently to learn using Linux. I want to write a script in bash shell to run a serial job on a cluster. I have been searching for hints and instructions on how to write such a script. I ...
0
votes
2answers
239 views

how to run .dump command in linux? [closed]

I want to create dump file of sqlite database from java but I can't run the below command from linux. I got the help of windows and I tried with linux but it appears one terminal nothing more than ...
2
votes
1answer
218 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 ...
2
votes
1answer
97 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? ...
1
vote
1answer
90 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"?
7
votes
3answers
2k 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 ...
1
vote
3answers
370 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 ...
4
votes
4answers
1k 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 ...
2
votes
1answer
2k 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
2answers
94 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
1answer
128 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> || ...
3
votes
2answers
430 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 ...
0
votes
0answers
1k views

IBM V7000 scripts for monitoring

Hello (I'm no hard core coder:), I try to develop a script to do some very basic monitoring on an IBM SVC. My goal is to get some information about the nodes and my quroum status and then send ...
0
votes
4answers
134 views

concatenating multiple files with multiple headers

Im trying to concatenate multiple files with multiple headers to have one file with all the information in it for example. File 1: Numbers 1 2 3 Letters A B C File 2: Numbers 4 5 6 Letters D E ...
2
votes
1answer
409 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 ...
3
votes
1answer
248 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
2answers
238 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 ...
7
votes
5answers
26k 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. ...
2
votes
2answers
1k 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
146 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 ...
3
votes
1answer
419 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 ...
2
votes
2answers
1k 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
390 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
150 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/*" ...
18
votes
1answer
545 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 ...
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 ...
11
votes
2answers
6k 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
543 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 ...
0
votes
1answer
289 views

Run a script after some command were executed

I have a list of scripts ./myscript <param> | grep "asd" ./myotherscript <param> <param> > file ... How can I automaticaly run another script when one of these command in the ...