我缺少一些细微之处。我尝试在命令下运行,但是没有用。你能帮忙吗?
ls | awk '{ split($1,a,".gz")} {cp " " $1 " " a[1]".gz"}'
Run Code Online (Sandbox Code Playgroud)
虽然当我尝试打印时显示复制命令。
ls | awk '{ split($1,a,".gz")} {print "cp" " " $1 " " a[1]".gz"}'
Run Code Online (Sandbox Code Playgroud)
不知道问题出在哪里。任何指针都会有所帮助
我对使用Apache Spark设置日志记录非常困惑.Apache spark使用Log4j进行日志记录,它会生成大量的日志数据.有没有办法为spark日志设置log4j并使用logback进行应用程序日志.我非常熟悉logback,但似乎 spark只支持log4j.下面的代码工作正常,直到我介绍了apache spark.在这方面的任何帮助都会有所帮助.
import com.typesafe.scalalogging.LazyLogging
import scala.util.{Failure, Success}
import scala.xml.{Elem, XML}
object MainApp extends App with LazyLogging {
val currency = new YahooCurrencyLoader() with CurrencyParameters
val ccy = currency.getXML(currency.ccyUrl) match {
case Success(v) => XML.save("PreviousRun.xml",v); logger.info("XML has been saved for use")
case Failure(ex) => logger.error("XML extraction failed. Look at Yahoo extraction class. ${ex.getMessage}" )
}
val xmllocation: String = "./PreviousRun.xml"
val loadxml: Elem = XML.loadFile(xmllocation)
//print(loadxml)
//print(currency.findCurrency(loadxml,"GBP"))
logger.info("USD CAD Cross is " + currency.findCurrency(loadxml,"CAD").head)
Run Code Online (Sandbox Code Playgroud) 我有清单(2,5,7,15,10),预期结果是(2,10,70,1050,10500)实际上是它以前的元素的乘法例如(2,2*5,2*5*7,2*5*7*15,2*5*7*15*10).我试过这个半烘焙的解决方案,但似乎我对foldLeft感到困惑.
任何帮助将不胜感激.
val lis = List(2, 5, 7, 15, 10) //> lis : List[Int] = List(2, 5, 7, 15, 10)
lis.head //> res0: Int = 2
lis.drop(1) //> res1: List[Int] = List(5, 7, 15, 10)
lis.tail //> res2: List[Int] = List(5, 7, 15, 10)
lis.drop(1).foldLeft(lis) {
(r,c) =>
println(r,c)
r.tail
} //> (List(2, 5, 7, 15, 10),5)
//| (List(5, 7, 15, 10),7)
//| (List(7, 15, 10),15)
//| (List(15, 10),10)
//| res3: List[Int] = List(10)
Run Code Online (Sandbox Code Playgroud)