Search Results

Search: Posts Made By: vikatakavi
3,729
Posted By Corona688
Do not use echo -e, do not use echo -n. printf...
Do not use echo -e, do not use echo -n.
printf "%s\n" "mystring"
3,729
Posted By wisecracker
Minor re-write... OSX 10.7.5, default bash...
Minor re-write...
OSX 10.7.5, default bash terminal:-
#!/bin/bash
# nl_date.sh
> /tmp/txt
DATE=$1
myview()
{
base_name=$1
echo "$base_name$DATE" >> /tmp/txt
}
myview sample3030
myview...
3,729
Posted By shamrock
Change the echo to print...
Change the echo to print...
3,729
Posted By wisecracker
Try:- echo -e "${base_name}${DATE}">>...
Try:-
echo -e "${base_name}${DATE}">> /path/to/file/txt
1,934
Posted By Yoda
I guess it is extracting, but it will extract it...
I guess it is extracting, but it will extract it to the current working directory where you are running your script.

You have to specify the directory:
tar -zxvf /path/to/the/file/file.tar.gz -C...
748
Posted By wisecracker
Try:- [ ! -f /path/to/file ]
Try:-
[ ! -f /path/to/file ]
748
Posted By port43
No, it should be if [ ! -f /path/to/file ]
No, it should be if [ ! -f /path/to/file ]
1,385
Posted By RudiC
Depending on the shell you use, which you fail to...
Depending on the shell you use, which you fail to mention, you could also tryfor file in 2014-02-01_{aaaa,bbbb,cccc,dddd}.txt;
1,385
Posted By MadeInGermany
It searches the files in the current directory. ...
It searches the files in the current directory.
Either change to the desired directory first
cd /path/to/files || exitOr put the path into a variable and prefix it every time:
fpath=/path/to/files...
1,444
Posted By Corona688
It overwrites the file. But you get the output...
It overwrites the file. But you get the output of the entire loop in the file -- it gets opened once and written to lots of times.
1,444
Posted By Yoda
Pass filename as input to sed: for f in...
Pass filename as input to sed:
for f in path/to/files/date_*.csv
do
sed '1d' "$f"
done > merge.csv
1,338
Posted By DGPickett
#!/bin/bash mysub(){ if [ $1 -eq 0 ] ...
#!/bin/bash

mysub(){
if [ $1 -eq 0 ]
then
echo "NO CHANGES ARE NEEDED"
exit
else
sed -i '1i'"$2" $3
echo "ADDED HEADER"
fi
)

zcat 2013-12-26_file1.csv.gz >...
1,137
Posted By alister
Read man test or check your shell's manual page...
Read man test or check your shell's manual page (ksh and bash, for example, have a builtin version that they document).

Regards,
Alister
1,884
Posted By jim mcnamara
If you actually have multiple formats like: ...
If you actually have multiple formats like:

yyyy/mm/dd
Wed 9 Sep 2009

And so on, then cleaning them up can be a nightmare. Try reading the tsv into Excel, and then have Excel produce a fixed...
1,884
Posted By Skrynesaver
So long as you have some consistency in the date...
So long as you have some consistency in the date format something like the following (adapted to your set of date string types)

#!/usr/bin/perl

use strict;
use warnings;

my %MON=qw(JAN 1...
1,480
Posted By Corona688
Searching for password in man unzip: ...
Searching for password in man unzip:

-P password
use password to decrypt encrypted zipfile entries (if any).
THIS IS INSECURE! Many multi-user ...
1,055
Posted By Skrynesaver
add a block like the following to the start of...
add a block like the following to the start of the run to keep track of the counter in a file.

$next=$(( $(cat .last_run) + 1 ))
echo $next >> .last_run
1,092
Posted By Yoda
Use substring extraction: mkdir...
Use substring extraction:
mkdir ${INPUTDATE:2:2} ${INPUTDATE:4:2} ${INPUTDATE:6:2}
Syntax:
${string:position:length}
1,276
Posted By hanson44
I'm not sure what the hadoop command is doing....
I'm not sure what the hadoop command is doing. Anyway, maybe this might work:

SOURCE=/path/to/files/
find "$SOURCE" -type f -mtime -1 -exec cp -v "{}" /usr/path/ \;
2,072
Posted By Corona688
Your program has already quit when you see that...
Your program has already quit when you see that message -- it just looks odd, because nohup has printed junk overtop of your prompt right after.

Normally this doesn't happen because the shell...
2,102
Posted By Yoda
awk ' /10000/ { ...
awk '
/10000/ { # Search if pattern: 10000 present in current record
sub(/\/.*/, x, $NF) # If found, substitute every character...
2,102
Posted By Yoda
var=$( netstat -plen | awk...
var=$( netstat -plen | awk '/10000/{sub(/\/.*/,x,$NF);print $NF}' )
1,887
Posted By PikK45
find /path/to/logs/ -mtime +10 ! \( -name...
find /path/to/logs/ -mtime +10 ! \( -name '*.info' -o -name '*.extn' -o .... \) -exec echo '{}' ';'
1,887
Posted By Corona688
Use https://www.unix.com/images/editor/code.png...
Use https://www.unix.com/images/editor/code.png tags for code, please.

find is already recursive -- looks inside folders -- so you don't need to put it in a loop.

It will also take a -name...
1,887
Posted By Yoda
Use logical not ! to exclude such files: !...
Use logical not ! to exclude such files:
! -name "*.info"
Showing results 1 to 25 of 25

 
All times are GMT -4. The time now is 02:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy