Tagged Questions
0
votes
2answers
26 views
need help in making script
I want to automate one task in UNIX and make one script.
There is directory in which everyday 2 files comes and that files come anytime in between 10 pm to 1 am.
file name is ...
7
votes
2answers
90 views
Are quotes needed for local variable assignment?
Can I safely omit quotes on the right side of a local assignment?
function foo {
local myvar=${bar}
stuff()
}
I'm mainly interested in bash, but any info on corner cases in other shells are ...
17
votes
9answers
662 views
for vs find in bash
When looping through files there are two ways:
1. use a for-loop
for f in *; do
echo "$f"
done
2. use find
find * -prune | while read f; do
echo "$f"
done
Assuming these two loops will ...
2
votes
4answers
105 views
How to catch an error in a linux bash script?
I made the following script:
# !/bin/bash
# OUTPUT-COLORING
red='\e[0;31m'
green='\e[0;32m'
NC='\e[0m' # No Color
# FUNCTIONS
# directoryExists - Does the directory exist?
function directoryExists ...
0
votes
1answer
746 views
Can I redirect output to a log file and background a process at the same time?
Can I redirect output to a log file and background a process at the same time?
In other words, can I do something like this?
nohup java -jar myProgram.jar 2>$1 > output.log &
Or, is that ...
1
vote
1answer
37 views
while loop is running only once?
I am trying to make a clip out of video file by playing it only for certain interval.
make_mclip.sh
#!/bin/bash
mediafile=$@
mediafile_fullpath=$PWD/./$mediafile
tmpedlfile=$(mktemp)
mplayer ...
3
votes
2answers
79 views
Bash-script. Shift seconds
Maybe somebody can help me. In bash I don't know how to do that. I need to do a bash-script. At stdin I have .srt file of subtitles in this format:
num
HH:MM:SS,SSS --> HH:MM:SS,SSS
text line 1
...
0
votes
5answers
63 views
How can I modify variables
I have the following variable:
col=1,3,4,
Is there anyway to select the numbers within the variable: (i.e. 1 3 4 and work with them?
Such as choosing the "1", "3", or "4" column from a .txt file?
...
1
vote
1answer
382 views
Script that unpacks a initrd, allows editing of the preseed.cfg and the packs it to cpio and gzip again
I want to program a script that allows what is said in the title. So basically I gunzip the initrd, than unpack the cpio, open vi to allow editing, save, pack with cpio, and gzip again, so nothing ...
1
vote
1answer
88 views
What is the difference between ' and "? [duplicate]
I tried to create a text file in a bash script.
The echo command spans multiple lines and has some double quotes "".
#!/bin/bash
echo "blabla bla bla bla "blabla"
bla bla " bla bla bla"
and so on ...
0
votes
0answers
19 views
When adding a ip via ifcfg how do you have it auto increment the clonenum?
I'm writing a script that adds ips to a multihomed machine. I'm not allowed to use network-scripts folder because well that's what they said. They also stated they wanted to clone num to increase. ...
4
votes
1answer
59 views
returncode of command in a pipline [duplicate]
The following script runs on Solaris using /bin/ksh and on Linux using /bin/sh
cmd | tee -a cmd.log | tail
exit $?
The output of cmd is saved in a file cmd.log and the last lines are displayed on ...
1
vote
1answer
64 views
Script to delete text files
I was trying to make a script that searches for all ASCII text files in the directory that you give and after that writes path of every file to a text file. After that it suppose to show head of each ...
2
votes
4answers
56 views
Delete all files in directories except those whose path are listed in a file
Given the following files:
data/A/a.txt
data/B/b.pdf
...
date/P/whatever.log
...
data/Z/z.jpg
I would like to delete all files in the data/A/, data/B/, ..., data/Z/ directories except those files ...
3
votes
2answers
51 views
Running commands after event based outputs
there are commands like
iwevent
or
tcpdump -n src host x.x.x.x
that send to the stdout some lines when something happens. Is there any form of running some command inmmediatly after a ...