Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: vikatakavi
2,265
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"
2,265
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...
2,265
Posted By shamrock
Change the echo to print...
Change the echo to print...
2,265
Posted By wisecracker
Try:- echo -e "${base_name}${DATE}">>...
Try:-
echo -e "${base_name}${DATE}">> /path/to/file/txt
1,451
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...
535
Posted By wisecracker
Try:- [ ! -f /path/to/file ]
Try:-
[ ! -f /path/to/file ]
535
Posted By port43
No, it should be if [ ! -f /path/to/file ]
No, it should be if [ ! -f /path/to/file ]
1,043
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,043
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...
948
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.
948
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
930
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 >...
750
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
942
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...
942
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,008
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 ...
733
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
888
Posted By Yoda
Use substring extraction: mkdir...
Use substring extraction:
mkdir ${INPUTDATE:2:2} ${INPUTDATE:4:2} ${INPUTDATE:6:2}
Syntax:
${string:position:length}
816
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/ \;
1,308
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...
1,457
Posted By Yoda
awk ' /10000/ { ...
awk '
/10000/ { # Search if pattern: 10000 present in current record
sub(/\/.*/, x, $NF) # If found, substitute every character...
1,457
Posted By Yoda
var=$( netstat -plen | awk...
var=$( netstat -plen | awk '/10000/{sub(/\/.*/,x,$NF);print $NF}' )
1,340
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,340
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,340
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

 

Featured Tech Videos

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